Class TimeZoneUtils

java.lang.Object
overit.geocallapp.utilities.core.timezone.TimeZoneUtils

public class TimeZoneUtils extends Object
Utility class providing time zone resolution and date conversion operations.
This class offers static methods for resolving time zones using annotation-based configuration and converting dates between different timezone representations. It supports automatic time zone resolution through TimeZoneResolver annotations and provides various date conversion utilities for working with ZonedDateTime and Date objects.
Since:
1.0
  • Method Details

    • getTimeZone

      public static final <T> TimeZone getTimeZone(Class<?> cls, Object firstItem, Object secondItem)
      Resolves a TimeZone using annotation-based configuration with fallback objects.
      Type Parameters:
      T - the type of data used for timezone resolution
      Parameters:
      cls - the class to check for TimeZoneResolver annotation
      firstItem - the primary object to extract timezone data from
      secondItem - the fallback object to extract timezone data from
      Returns:
      the resolved TimeZone, or system default if resolution fails
    • getLocalDate

      public static Date getLocalDate(ZonedDateTime source, TimeZone timeZone)
      Converts a ZonedDateTime to a local Date using the specified timezone.
      Parameters:
      source - the ZonedDateTime to convert
      timeZone - the target TimeZone for conversion
      Returns:
      the converted local Date, or null if source is null
    • getCentralDate

      public static Date getCentralDate(ZonedDateTime source)
      Converts a ZonedDateTime to a central Date in the application server timezone.
      Parameters:
      source - the ZonedDateTime to convert
      Returns:
      the converted central Date, or null if source is null
    • getSymbolicDate

      public static Date getSymbolicDate(ZonedDateTime source)
      Converts a ZonedDateTime to a symbolic Date without changing the date value.
      Parameters:
      source - the ZonedDateTime to convert
      Returns:
      the converted symbolic Date, or null if source is null
    • getLocalZonedDateTime

      public static ZonedDateTime getLocalZonedDateTime(Date source, TimeZone timeZone)
      Converts a Date to a local ZonedDateTime with the specified timezone.
      Parameters:
      source - the Date to convert (in application server timezone)
      timeZone - the target TimeZone for the output
      Returns:
      the converted local ZonedDateTime
    • getCentralOrSymbolicZonedDateTime

      public static ZonedDateTime getCentralOrSymbolicZonedDateTime(Date source)
      Converts a Date to a central or symbolic ZonedDateTime without changing time or timezone.
      Parameters:
      source - the Date to convert
      Returns:
      the converted central/symbolic ZonedDateTime