Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to match a string to the device time
    primarykey
    data
    text
    <p>When my device time is between or equal to the starting time and ending time, I want it to show me <code>ChogadiaName</code>. This is my method where I'm fetching the time:</p> <pre><code>/*{"chogadia":[{"ChogadiaName":1,"StartTime":"5:31:19 AM","EndTime":"7:14:15 AM","Effect":"Inauspicious Chogadia"},{"ChogadiaName":3,"StartTime":"8:57:10 AM","EndTime":"10:40:5 AM","Effect":"Auspicious Chogadia"},{"ChogadiaName":4,"StartTime":"10:40:5 AM","EndTime":"12:22:59 AM","Effect":"Auspicious Chogadia"}]}*/ public class ChogadiaParser { public static ArrayList&lt;Chogadia&gt; mList=new ArrayList&lt;Chogadia&gt;(); public static Chogadia mChogadia; public static String response,chogadia; public static String Lucky="Auspicious Chogadia"; public static String UnLucky="Inauspicious Chogadia"; public static void GroupResult(String url){ try{ JSONArray jArray; JSONObject jObject; response=GetJsonObject.sendRequest(url); if(response == null){ return; } jObject=new JSONObject(response); jArray=jObject.getJSONArray("chogadia"); mList.clear(); for(int i=0;i&lt;jArray.length();i++){ mChogadia=new Chogadia(); jObject=jArray.getJSONObject(i); mChogadia.SetChogadiaName(jObject.getString("ChogadiaName")); mChogadia.SetStartTime(jObject.getString("StartTime")); mChogadia.SetEndTime(jObject.getString("EndTime")); mChogadia.SetEffect(jObject.getString("Effect")); mList.add(mChogadia); if(mathcTime(jObject.getString("StartTime"),jObject.getString("EndTime"))){ System.out.println("Matched Name Is: " + jObject.getString("ChogadiaName")); break; // break loop } } }catch(Exception e){ e.printStackTrace(); } } private static boolean mathcTime(String stime,String eTime) { SimpleDateFormat ft = new SimpleDateFormat("hh:mm:ss"); try { Date ct = new Date(); Date st = ft.parse(stime); Date et=ft.parse(eTime);; long currentTime = ((ct.getHours()*60)*60) + (ct.getMinutes()*60) + (ct.getSeconds()); long startTime = ((st.getHours()*60)*60) + (st.getMinutes()*60) + (st.getSeconds()); long endTime = ((et.getHours()*60)*60) + (et.getMinutes()*60) + (et.getSeconds()); if(currentTime&gt;=startTime || currentTime&lt;=endTime){ return true; }else{ return false; } } catch (Exception e) { } return false; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload