java.lang.Object
io.github.perceivechuchu.datetimeutil.timezone.TimeZoneUtil

public final class TimeZoneUtil extends Object
This class is a utility for time zones
Since:
1.0.0
Author:
Perceive Chuchu
  • Method Details

    • getAllTimeZones

      public static List<TimeZoneDetail> 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

      public static boolean isValidTimeZoneId(String timeZoneId)
      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

      public static String getTimeZoneAbbreviation(String timeZoneId)
      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

      public static List<TimeZoneDetail> searchTimeZonesByOffsetText(String offsetText)
      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