List of utility methods to do Time Format
long | getTimeFromString(String time, SimpleDateFormat formatter) get Time From String if (time.toLowerCase().equals("latest")) { return Long.MAX_VALUE; if (time.toLowerCase().equals("bot")) { return Long.MIN_VALUE; return formatter.parse(time).getTime(); |
Date | getTimeFromString(String timeStr, String format) get Time From String if (format == null || format.trim().equals("")) { sdf.applyPattern(FORMAT_DATE_TIME); } else { sdf.applyPattern(format); try { return sdf.parse(timeStr); } catch (ParseException e) { ... |
String | getTimeInProvenanceFormat(Date date) get Time In Provenance Format SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX"); sdf.setTimeZone(TimeZone.getDefault()); return sdf.format(date); |
DateFormat | getTimeOnlyDateFormat() get Time Only Date Format return new SimpleDateFormat("HH:mm:ss z"); |
String | getTimeOnlyWithNumber() get Time Only With Number SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss"); return formatter.format(new Date()); |
String | getTimeQuantum(String strDate, String format) get Time Quantum Date mDate = getDateByFormat(strDate, format); int hour = mDate.getHours(); if (hour >= 12) return "PM"; else return "AM"; |
String | getTimeStringFormatedForSWANWithDelim(final Object pObjTime, final String pStrDelim) get Time String Formated For SWAN With Delim String lStrTimeRes = ""; SimpleDateFormat lDateFormatter; lDateFormatter = new SimpleDateFormat("yyyyMMdd" + pStrDelim + "HHmmss"); if (pObjTime instanceof String) { lStrTimeRes = (String) pObjTime; SimpleDateFormat lDateFormatterLoc = new SimpleDateFormat(); try { Date lDate = lDateFormatterLoc.parse(lStrTimeRes); ... |
String | getTimeSystem(String formatTime) get Time System String timeSystem = null; try { if (formatTime == null) { formatTime = "HH:mm:ss"; java.text.SimpleDateFormat format = new java.text.SimpleDateFormat(formatTime); java.util.Date date = new java.util.Date(); timeSystem = format.format(date); ... |
long | getTwoTimeInterval(String startTime, String endTime, String format) get Two Time Interval SimpleDateFormat df = new SimpleDateFormat(format); try { Date starDate = df.parse(startTime); Date endDate = df.parse(endTime); return endDate.getTime() - starDate.getTime(); } catch (ParseException e) { e.printStackTrace(); return 0; |
SimpleDateFormat | getUniversalDateTimeFormat() Returns a formatter for the universal date/time format return new SimpleDateFormat(UNIVERSAL_TIMEFORMAT); |