List of utility methods to do Time Format
String | stdTimeFormat(Date date) Formats a date by WGAs default time format HH:mm:SS return DATEFORMAT_STANDARD.format(date);
|
long | string2Long(String sourceTime, String dataFormat) string Long long longTime = 0L; DateFormat f = new SimpleDateFormat(dataFormat); Date d = null; try { d = f.parse(sourceTime); } catch (ParseException e) { e.printStackTrace(); longTime = d.getTime(); return longTime; |
long | string2long(String sourceTime, String dataFormat) stringlong long longTime = 0L; DateFormat f = new SimpleDateFormat(dataFormat); Date d = null; try { d = f.parse(sourceTime); } catch (ParseException e) { e.printStackTrace(); if (null == d) longTime = 0; else longTime = d.getTime(); return longTime; |
String | stringDateTimeFormat(String dt2Format) string Date Time Format return new SimpleDateFormat(DATETIME_WITHOUT_SS_FORMAT).format(parseDateTime(dt2Format)); |
long | stringTimeToLongTime(String time, String format) string Time To Long Time if (format.isEmpty()) format = "yyyyMMdd-HHmmss-SSS"; try { return new SimpleDateFormat(format).parse(time).getTime(); } catch (ParseException e) { throw new IOException(e); |
Date | stringToTime(String format, String sDate) string To Time DateFormat df = new SimpleDateFormat(format); Date _date = df.parse(sDate); if (timeToString(format, _date).equals(sDate)) { return _date; } else { throw new Exception(sDate + " is error"); |
String | time2Date(Integer time, String format) time Date String date = ""; SimpleDateFormat sdf = new SimpleDateFormat(format); date = sdf.format(new Date(time * 1000l)); return date; |
String | time2String(Date time, DateFormat dateFormat) time String if (time == null) return null; return dateFormat.format(time); |
String | timeFormatDate(Date d) time Format Date return timeFormat.format(d);
|
String | timeFormatNano(long delta) time Format Nano StringBuilder sb = new StringBuilder(); if (delta > ONE_BILLION * 60) { sb.append(FORMAT_DOUBLE_NO_FRACTION.format(delta / (ONE_BILLION * 60)) + ":"); } else { sb.append("00:"); if (delta > ONE_BILLION) { sb.append(FORMAT_DOUBLE_NO_FRACTION.format(delta / ONE_BILLION) + "::"); ... |