Java Utililty Methods TimeZone Create

List of utility methods to do TimeZone Create

Description

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

Method

DategetUserTimeZoneDate(String userTimezone)
get User Time Zone Date
Date date = new Date();
System.out.println(date);
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy");
sdf.setTimeZone(TimeZone.getTimeZone(userTimezone)); 
String datestr = sdf.format(date);
System.out.println(datestr);
String[] datearr = datestr.split(" ");
String newstr = datestr.replace(datearr[4], " ");
...
voidtestSimpleTimeZone()
test Simple Time Zone
SimpleTimeZone zone = new SimpleTimeZone(-28800000, "America/Los_Angeles");
System.out.println(zone);
TimeZonetoTimeZone(int gmtOffset)
Returns a TimeZone object based upon an hour offset from GMT.
if (gmtOffset > 12 || gmtOffset < -14) {
    throw new IllegalArgumentException("Invalid GMT offset");
String tzId = gmtOffset > 0 ? "Etc/GMT+" : "Etc/GMT";
return TimeZone.getTimeZone(tzId + gmtOffset);
TimeZonetoTimeZone(String value)
to Time Zone
TimeZone result = null;
if (value != null) {
    result = TimeZone.getTimeZone(value);
return result;
TimeZonetoTimeZone(String zone)
Lookup timezone by ID.
if (zone == null) {
    return null;
return TimeZone.getTimeZone(zone);