List of utility methods to do Date Format
String | dateTime2Str(Date date, String pattern) date Time Str if (null == date) { return null; if (null == pattern) { pattern = DEFAULT_DATE_TIME_FORMAT; SimpleDateFormat format = new SimpleDateFormat(); format.applyPattern(pattern); ... |
String | dateTime2String(Date value) date Time String if (value != null) { SimpleDateFormat dateTime = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); return dateTime.format(value); return ""; |
String | dateTime2StringFs(Date date) Date ---> String (yyyyMMddHHmmss) return date2String(date, "yyyyMMddHHmmss"); |
String | dateTimeFormat(Date dateTime) Formats a given date+time value to an ISO 8601 string. DateFormat iso8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US); iso8601.setTimeZone(UTC); return iso8601.format(dateTime); |
String | DateTimeFormat(final Date date) Date Time Format SimpleDateFormat format = new SimpleDateFormat("yyy-MM-dd hh:mm:ss"); return format.format(date); |
String | dateTimeFormatterDate(Date date) date Time Formatter Date if (date != null) { return dateTimeFormatter.format(date); return ""; |
long | dateTimeToMillis(String dateTime, String format) date Time To Millis SimpleDateFormat dateFormat = new SimpleDateFormat(format); try { return dateFormat.parse(dateTime).getTime(); } catch (ParseException e) { return -1; |
String | dateTimeToStr(Date date, String format) date Time To Str String _timeZone = System.getProperty("user.timezone"); TimeZone timeZone = null; if (_timeZone == null || "".equals(_timeZone) || "UTC".equals(_timeZone)) { timeZone = TimeZone.getDefault(); } else { timeZone = TimeZone.getTimeZone("Asia/Shanghai"); SimpleDateFormat dateFormat = new SimpleDateFormat(format); ... |
String | dateTimeToZuluFormat(DateTime dateTime) date Time To Zulu Format final String ISO_FORMAT = "yyyy-MM-dd'T'HH:mm:ss:SSzzz"; final SimpleDateFormat sdf = new SimpleDateFormat(ISO_FORMAT); final TimeZone utc = TimeZone.getTimeZone("UTC"); sdf.setTimeZone(utc); return sdf.format(dateTime.toDate()); |
String | formatD(Date date) format D SimpleDateFormat sdf = new SimpleDateFormat(FORMAT_STYLE_D); return sdf.format(date); |