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

SimpleDateFormatgetDefaultDateFormatWithoutTimeZone(TimeZone zone)
get Default Date Format Without Time Zone
SimpleDateFormat simpleDateFormat = DATE_FORMAT_WITHOUT_TIME_ZONE_MAP.get(zone);
if (simpleDateFormat == null) {
    simpleDateFormat = DATE_FORMAT_WITHOUT_TIME_ZONE_MAP.get(null);
    SimpleDateFormat clone = (SimpleDateFormat) simpleDateFormat.clone();
    clone.setTimeZone(zone);
    DATE_FORMAT_WITHOUT_TIME_ZONE_MAP.put(zone, clone);
return simpleDateFormat;
...
SimpleDateFormatgetDefaultDateFormatWithTimeZone()
get Default Date Format With Time Zone
return DATE_FORMAT_WITH_TIME_ZONE;
StringgetFormattedTime(Date time, String formatTime, String timezone)
get Formatted Time
if (time == null) {
    return "";
SimpleDateFormat sdf = new SimpleDateFormat(formatTime);
TimeZone tz = TimeZone.getTimeZone(timezone);
sdf.setTimeZone(tz);
return sdf.format(time);
SimpleDateFormatgetSimpleDateFormat(TimeZone timeZone, String pattern)
Returns a SimpleDateFormat for the specified time zone and formatting pattern (as specified by SimpleDateFormat).
SimpleDateFormat formatter = new SimpleDateFormat(pattern);
formatter.setLenient(false);
formatter.setTimeZone(timeZone);
return formatter;
StringgetString(Date dt, DateFormat df, TimeZone to)
Get the timezone specific string.
df.setTimeZone(to);
return df.format(dt);
StringgetTimeByZoneAndFormat(Date date, TimeZone zone, String format)
get Time By Zone And Format
final DateFormat formatter = new SimpleDateFormat(format, LOCALE_US);
formatter.setTimeZone(zone);
return formatter.format(date);
DateTimegetTimeWithFormat(String stringDate, String dateFormat, DateTimeZone timeZone, Locale locale)
e.g.
locale = locale != null ? locale : Locale.ENGLISH;
timeZone = timeZone != null ? timeZone : getServerDateTimeZone();
try {
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormat, locale);
    simpleDateFormat.setTimeZone(TimeZone.getTimeZone(timeZone.getID()));
    Date parsedDate = simpleDateFormat.parse(stringDate);
    return new DateTime(parsedDate, timeZone);
} catch (ParseException e) {
...
StringgetTimezoneFormattedString(Date date, String timezone)
get Timezone Formatted String
TimeZone tz = null;
if (timezone == null) {
    tz = NEW_YORK;
} else {
    tz = TimeZone.getTimeZone(timezone);
Calendar cal = Calendar.getInstance(tz, Locale.US);
cal.setTime(date);
...
StringgetUserToServerDateTimeString(TimeZone timeZone, int dateFormat, int timeFormat, String date)
Gets the dateString attribute of the DateUtils object
return getUserToServerDateTimeString(timeZone, dateFormat, timeFormat, date, Locale.getDefault());
SimpleDateFormatgetZfgcTimeZoneDateFormat(String timezone)
get Zfgc Time Zone Date Format
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy z");
sdf.setTimeZone(TimeZone.getTimeZone(timezone));
return sdf;