Description
- org.joget.commons.util.TimeZoneUtil
- Under wflow-commons module
- Utility methods to deal with Time Zone
Code Sample
import java.util.Date; import org.joget.commons.util.TimeZoneUtil; import org.joget.apps.app.service.AppUtil; //Format current date to System/User selected timezone and date format String dateString = TimeZoneUtil.convertToTimeZone(new Date(), null, AppUtil.getAppDateFormat());
Methods
convertToTimeZone
public static java.lang.String convertToTimeZone(java.lang.Date time, java.lang.String gmt, java.lang.String format)
Convert Date to String based on GMT/Timezone ID and Date Format.
Parameters:
gmt - GMT ("-12" to "12") or Timezone ID, NULL to use System/User selected timezone.
format - follow java.text.SimpleDateFormat syntax.
getList
public static java.util.Map<java.lang.String, java.lang.String> getList()
Retrieve a list of Time Zone.
Return a map of time zone id and its description
getServerTimeZone
public static java.lang.String getServerTimeZone()
Retrieve Server Time Zone in GMT format
getServerTimeZoneID
public static java.lang.String getServerTimeZoneID()
Retrieve Server Time Zone ID
getTimeZoneByGMT
public static java.lang.String getTimeZoneByGMT(java.lang.String gmt)
Get Time Zone ID by GMT