Class TimeZoneUtil
java.lang.Object
io.github.perceivechuchu.datetimeutil.timezone.TimeZoneUtil
This class is a utility for time zones
- Since:
- 1.0.0
- Author:
- Perceive Chuchu
-
Method Summary
Modifier and TypeMethodDescriptionstatic List<TimeZoneDetail>Gets all available time zones.static StringgetTimeZoneAbbreviation(String timeZoneId) Gets the abbreviation for a time zonestatic booleanisValidTimeZoneId(String timeZoneId) Checks if a time zone id is validstatic List<TimeZoneDetail>searchTimeZonesByOffsetText(String offsetText) Search time zones by the offset text e.g.
-
Method Details
-
getAllTimeZones
Gets all available time zones. This was implemented as a singleton to improve performance by fetching the already existing list in memory- Returns:
- the list of all time zone details
- Since:
- 1.0.0
-
isValidTimeZoneId
Checks if a time zone id is valid- Parameters:
timeZoneId- the time zone id to be used in the conversion e.g. "Africa/Johannesburg"- Returns:
- the boolean value showing the validation result: "true or false"
- Throws:
IllegalArgumentException- if parameter is not valid- Since:
- 1.0.0
-
getTimeZoneAbbreviation
Gets the abbreviation for a time zone- Parameters:
timeZoneId- the time zone id to be used in the conversion e.g. "Africa/Johannesburg"- Returns:
- the abbreviation for a time zone e.g. abbreviation for zone id "Africa/Johannesburg" is "SAST"
- Throws:
IllegalArgumentException- if parameter is not valid- Since:
- 1.0.0
-
searchTimeZonesByOffsetText
Search time zones by the offset text e.g. search by "+02:00"- Parameters:
offsetText- The difference in hours and minutes from Coordinated Universal Time (UTC) e.g. "+02:00"- Returns:
- the list of time zone details
- Throws:
IllegalArgumentException- if parameter is not valid- Since:
- 1.0.0
-