List of usage examples for android.text.format Time parse
public boolean parse(String s)
From source file:Main.java
public static long convertStrTimeToLong(String time_str) { /* input time string should have * - RFC 2445 DATETIM type: "%Y%m%dT%H%M%S" *///from w w w . ja v a 2 s . com Time time = new Time(); time.parse(time_str); return time.normalize(false); }
From source file:org.cinedroid.tasks.impl.RetrievePerformancesTask.java
/** * Removes any times which have passed from the list * /*from ww w . j a v a 2s . c o m*/ * @param results */ private void filterPastDates(final FilmDate filmDate) { Time currentTime = new Time(); currentTime.setToNow(); Time performanceDate = new Time(); String date = filmDate.getDate(); performanceDate.parse(date); // Check if the performance date is before the current time. This will only be true in the situation that the filmDate represents // the current day, as the cineworld api does not return dates which have passed. If the object is the current date, the film // performances need filtering. if (currentTime.after(performanceDate)) { for (Iterator<FilmPerformance> i = filmDate.getPerformances().iterator(); i.hasNext();) { String time = i.next().getTime().replace(":", ""); // Get the time with the : removed. performanceDate.parse(String.format("%sT%s00", date, time)); Log.d(TAG, String.format("Checking %s", performanceDate.format("%d %b %H:%M"))); if (currentTime.after(performanceDate)) { Log.d(TAG, String.format("Removed %s", performanceDate.format("%d %b %H:%M"))); i.remove(); } } } Log.d(TAG, String.format("Current Time %s", currentTime.toString())); }
From source file:ch.mieng.meteo.mythenquai.mod.WeatherData.java
public long parseTime() { String str = getFullTimeStr(); Time time = new Time(); try {//from w w w . ja va2 s.co m String p = str.substring(6, 10) + str.substring(3, 5) + str.substring(0, 2) + "T" + str.substring(11, 13) + str.substring(14, 16) + "00" // secs ; //System.err.println("###P=["+p+"]"); time.parse(p); // 20081013T160000" return time.toMillis(true); } catch (Throwable e) { //System.err.println("###P ERROR "+e); return System.currentTimeMillis(); } }
From source file:com.android.bluetooth.map.BluetoothMapContent.java
private String setWhereFilterPeriod(BluetoothMapAppParams ap, FilterInfo fi) { String where = ""; if ((ap.getFilterPeriodBegin() != -1)) { if (fi.msgType == FilterInfo.TYPE_SMS) { where = " AND date >= " + ap.getFilterPeriodBegin(); } else if (fi.msgType == FilterInfo.TYPE_MMS) { where = " AND date >= " + (ap.getFilterPeriodBegin() / 1000L); } else {/*from w w w. j av a 2s.c om*/ Time time = new Time(); try { time.parse(ap.getFilterPeriodBeginString().trim()); where += " AND timeStamp >= " + time.toMillis(false); } catch (TimeFormatException e) { Log.d(TAG, "Bad formatted FilterPeriodBegin, Ignore" + ap.getFilterPeriodBeginString()); } } } if ((ap.getFilterPeriodEnd() != -1)) { if (fi.msgType == FilterInfo.TYPE_SMS) { where += " AND date <= " + ap.getFilterPeriodEnd(); } else if (fi.msgType == FilterInfo.TYPE_MMS) { where += " AND date <= " + (ap.getFilterPeriodEnd() / 1000L); } else { Time time = new Time(); try { time.parse(ap.getFilterPeriodEndString().trim()); where += " AND timeStamp <= " + time.toMillis(false); } catch (TimeFormatException e) { Log.d(TAG, "Bad formatted FilterPeriodEnd, Ignore" + ap.getFilterPeriodEndString()); } } } return where; }