List of utility methods to do Parse Time
long | parseTimeString(String time) parse Time String Date date; try { date = formatter.parse(time); return date.getTime(); } catch (ParseException e) { e.printStackTrace(); return 0; ... |
Long | parseTimeString(String timeString) Parse a date/time string and return its equivalent in milliseconds (using same time coordinate system as System.currentTimeMillis()). if (timeString == null) return null; if (isKMLTimeShift(timeString)) { timeString = timeString.trim(); int colonPosition = timeString.length() - 3; String newTimeString = timeString.substring(0, colonPosition); timeString = newTimeString + timeString.substring(colonPosition + 1, timeString.length()); try { DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:sszzzzz"); return df.parse(timeString).getTime(); } catch (ParseException ignored) { try { DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); return df.parse(timeString).getTime(); } catch (ParseException ignored) { try { DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); return df.parse(timeString).getTime(); } catch (ParseException ignored) { try { DateFormat df = new SimpleDateFormat("yyyy-MM"); return df.parse(timeString).getTime(); } catch (ParseException ignored) { try { DateFormat df = new SimpleDateFormat("yyyy"); return df.parse(timeString).getTime(); } catch (ParseException ignored) { return null; |
long | parseTimezoneOffset(String value) parse Timezone Offset int pos = value.indexOf(':'); if (pos == -1) { throw new ParseException("Invalid offset value: " + value, 0); String hours = value.substring(0, pos); String minutes = value.substring(pos + 1); return (Long.parseLong(hours) * 60 + Long.parseLong(minutes)) * 60; |