List of utility methods to do TimeZone Format
void | resolveTimeZone(SimpleDateFormat sdf, String timezone) Wrap TimeZone.getTimeZone so that reflection doesn't need to look for sun.util.calendar.ZoneInfo which causes warnings in some environments sdf.setTimeZone(TimeZone.getTimeZone(timezone)); |
Date | String2Date(String date, String formatPattern, Locale locale, TimeZone timeZone) String Date if ((formatPattern == null) || formatPattern.isEmpty()) { formatPattern = "yyyy-MM-dd HH:mm:ss"; SimpleDateFormat df = getDateFormat(formatPattern, locale, timeZone); return df.parse(date); |
String | string2Timezone(String srcFormater, String srcDateTime, String dstFormater, String dstTimeZoneId) string Timezone if (srcFormater == null || "".equals(srcFormater)) return null; if (srcDateTime == null || "".equals(srcDateTime)) return null; if (dstFormater == null || "".equals(dstFormater)) return null; if (dstTimeZoneId == null || "".equals(dstTimeZoneId)) return null; ... |
String | toAPITimeString(Date date, String format, String timeZone) to API Time String SimpleDateFormat dateFormatterAPI = null; dateFormatterAPI = new SimpleDateFormat(format); if (timeZone != null) dateFormatterAPI.setTimeZone(TimeZone.getTimeZone(timeZone)); return dateFormatterAPI.format(date); |
DateFormat | toTimeFormat(String timeFormat, TimeZone tz, Locale locale) Returns an initialized DateFormat object. DateFormat df = null; if (timeFormat == null) { df = DateFormat.getTimeInstance(DateFormat.MEDIUM, locale); } else { df = new SimpleDateFormat(timeFormat); df.setTimeZone(tz); return df; ... |