Class TimezoneResolverServiceImpl
java.lang.Object
ch.tocco.nice2.toolbox.impl.timezone.TimezoneResolverServiceImpl
- All Implemented Interfaces:
TimezoneResolverService
@Component
public class TimezoneResolverServiceImpl
extends Object
implements TimezoneResolverService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.joda.time.DateTimeZonegetCurrentDateTimeForGuiTimezone(Locale locale, @Nullable String pattern) org.joda.time.DateTimeZoneReturns the project-specific default timezone id.@Nullable org.joda.time.DateTimeZone@Nullable StringReturns the gui timezone id for the current user to be used in the gui right now.voidvoidsetDefaultTimezone(String defaultTimezone) voidsetTimezoneResolver(List<TimezoneResolver> timezoneResolver) withBestTimezone(org.joda.time.DateTimeZone dateTimeZone) Use a specifiedDateTimeZoneas 'best' timezone (i.e.Use the system's default timezone (i.e.
-
Constructor Details
-
TimezoneResolverServiceImpl
public TimezoneResolverServiceImpl(org.slf4j.Logger log)
-
-
Method Details
-
initialize
@PostConstruct public void initialize() -
getDefaultTimezoneId
Description copied from interface:TimezoneResolverServiceReturns the project-specific default timezone id.- Specified by:
getDefaultTimezoneIdin interfaceTimezoneResolverService- Returns:
- olson-tz name.
-
getTimezoneIdForGui
Description copied from interface:TimezoneResolverServiceReturns the gui timezone id for the current user to be used in the gui right now.- Specified by:
getTimezoneIdForGuiin interfaceTimezoneResolverService- Returns:
- olson-tz name, or
nullif unknown.
-
getBestTimezoneId
- Specified by:
getBestTimezoneIdin interfaceTimezoneResolverService- Returns:
- the id of the
user's timezoneif available, falls back to the id of theproject's default timezone.
-
getDefaultTimeZone
public org.joda.time.DateTimeZone getDefaultTimeZone()- Specified by:
getDefaultTimeZonein interfaceTimezoneResolverService- Returns:
- the project-specific default timezone
-
getBestTimezone
public org.joda.time.DateTimeZone getBestTimezone()- Specified by:
getBestTimezonein interfaceTimezoneResolverService- Returns:
- the
user's timezoneif available, falls back to theproject's default timezone
-
getTimezoneForGui
@Nullable public @Nullable org.joda.time.DateTimeZone getTimezoneForGui()- Specified by:
getTimezoneForGuiin interfaceTimezoneResolverService- Returns:
- returns the gui timezone for the current user
-
getCurrentDateTimeForGuiTimezone
- Specified by:
getCurrentDateTimeForGuiTimezonein interfaceTimezoneResolverService- Parameters:
locale- the locale to be used for the formatpattern- an optional pattern, a pattern with style "SS" will be used if null- Returns:
- the current date and time as a formatted string
-
withBestTimezone
Description copied from interface:TimezoneResolverServiceUse a specifiedDateTimeZoneas 'best' timezone (i.e. the timezone returned byTimezoneResolverService.getBestTimezone()instead of whatever was potentially set on the current request. Note: this does not influence calls toTimezoneResolverService.getTimezoneForGui(), as this will still return the timezone as set by the current request.- Specified by:
withBestTimezonein interfaceTimezoneResolverService- Parameters:
dateTimeZone- the timezone to be used- Returns:
- an invoker with the best timezone set to the specified timezone
-
withDefaultAsBestTimezone
Description copied from interface:TimezoneResolverServiceUse the system's default timezone (i.e. the timezone returned byTimezoneResolverService.getBestTimezone()) as 'best' timezone (i.e. the timezone returned byTimezoneResolverService.getBestTimezone()instead of whatever was potentially set on the current request. Note: this does not influence calls toTimezoneResolverService.getTimezoneForGui(), as this will still return the timezone as set by the current request.- Specified by:
withDefaultAsBestTimezonein interfaceTimezoneResolverService- Returns:
- an invoker with the best timezone set to the system's default timezone
-
setDefaultTimezone
- Parameters:
defaultTimezone- The timezone from the application.properties, eg "America/New_York".
-
setTimezoneResolver
-