List of utility methods to do Time Format
SimpleDateFormat | getXsdDateTimeFormat() Returns a SimpleDateFormat allowing to read and write ^^xsd:date return (SimpleDateFormat) XSD_DATE_TIME_FORMAT.clone();
|
DateTimeFormatter | getXSDFormatter(DateTime date) get XSD Formatter int len = 0; int millis = date.getMillisOfSecond(); if (millis > 0) { DecimalFormat df = new DecimalFormat(".###"); double d = millis / 1000.0; len = String.valueOf(df.format(d)).length() - 1; return getXSDFormatter(len); ... |
boolean | isDateFormat(String timeString) is Date Format SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); format.setLenient(false); try { format.parse(timeString); } catch (Exception e) { return false; return true; ... |
String | long2Datestr(long time, String format) long Datestr if (format == null || format.trim().equals("")) format = "yyyy-MM-dd HH:mm:ss"; SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(time); |
String | long2String(long longTime, String dataFormat) long String Date d = new Date(longTime); SimpleDateFormat s = new SimpleDateFormat(dataFormat); String str = s.format(d); return str; |
String | long2String(long longTime, String dataFormat) long String String str = ""; try { Date d = new Date(longTime); SimpleDateFormat s = new SimpleDateFormat(dataFormat); str = s.format(d); } catch (Exception e) { str = ""; return str; |
DateFormat | newDateTimeFormat() new Date Time Format SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); f.setTimeZone(TimeZone.getTimeZone("UTC")); return f; |
String | printDate(final long time, final String dateFormat) print Date Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(getDate(time, false) * 1000); SimpleDateFormat sdf = new SimpleDateFormat(dateFormat); return sdf.format(cal.getTime()); |
String | printFormatDate(long dateTime) print Format Date return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.").format(dateTime / 1000) + String.format("%06d", dateTime % 1000000); |
void | setDateTimeFormat(String format) Give the possibility to change to datetime format as it differs across several database systems dateTimeFormat.applyPattern(format); |