Java Utililty Methods TimeZone Format

List of utility methods to do TimeZone Format

Description

The list of methods to do TimeZone Format are organized into topic(s).

Method

voidresolveTimeZone(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));
DateString2Date(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);
Stringstring2Timezone(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;
...
StringtoAPITimeString(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);
DateFormattoTimeFormat(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;
...