/** * The time zone of this object (if given) or the time zone of the user if found in the ThreadLocalUserContext, otherwise {@link TimeZone#getDefault()}. * @see ThreadLocalUserContext#getUser() * @see ThreadLocalUserContext#getTimeZone() */ protected TimeZone getTimeZone() { if (timeZone != null) { return timeZone; } return ThreadLocalUserContext.getTimeZone(); } }
public final static DateTimeZone getDateTimeZone() { final TimeZone timeZone = getTimeZone(); return DateTimeZone.forTimeZone(timeZone); }
/** * @return Short name of day represented by the giving day. The context user's locale and time zone is considered. */ public static final String formatShortNameOfDay(final Date date) { final DateFormat df = new SimpleDateFormat("EE", ThreadLocalUserContext.getLocale()); df.setTimeZone(ThreadLocalUserContext.getTimeZone()); return df.format(date); }
public static final String getTimestampAsFilenameSuffix(final Date date) { if (date == null) { return "--"; } return getFilenameFormatTimestamp(ThreadLocalUserContext.getTimeZone()).format(date); }
public static Calendar getCalendar(TimeZone timeZone, Locale locale) { if (locale == null) { locale = ThreadLocalUserContext.getLocale(); } if (timeZone == null) { timeZone = ThreadLocalUserContext.getTimeZone(); } return Calendar.getInstance(timeZone, locale); }
/** * Converts a given date (in user's timeZone) to midnight of UTC timeZone. * @param date * @return */ public static Calendar getUTCMidnightCalendar(final Date date) { return getUTCMidnightCalendar(date, ThreadLocalUserContext.getTimeZone()); }
/** * Converts a given date (in user's timeZone) to midnight of UTC timeZone. * @param date * @return */ public static Calendar getMidnightCalendarFromUTC(final Date date) { return getMidnightCalendarFromUTC(date, ThreadLocalUserContext.getTimeZone()); }
/** * Takes time zone of context user if exist. * * @param date */ public static String formatIsoDate(final Date date) { return getIsoDateFormat(ThreadLocalUserContext.getTimeZone()).format(date); }
public static java.sql.Date convertDateToSqlDateInTheUsersTimeZone(final Date date) { if (date == null) { return null; } final TimeZone utc = TimeZone.getTimeZone("UTC"); final TimeZone usersTimeZone = ThreadLocalUserContext.getTimeZone(); final Date dateInUsersTimezone = convertDateIntoOtherTimezone(date, utc, usersTimeZone); return new java.sql.Date(dateInUsersTimezone.getTime()); }
private Calendar getValueFromFormOrData(final DatePanel datePanel) { final Calendar date = Calendar.getInstance(ThreadLocalUserContext.getTimeZone()); Calendar.getInstance(ThreadLocalUserContext.getTimeZone()); if (datePanel != null && datePanel.getConvertedInput() != null) { date.setTime(datePanel.getConvertedInput()); } else { date.setTime(data.getStartDate()); } return date; }
private void reloadList() { Calendar now = Calendar.getInstance(ThreadLocalUserContext.getTimeZone()); final List<VacationDO> list = vacationService.getActiveVacationForYear(employee, now.get(Calendar.YEAR), true); setCompleteList(list); }
/** * Uses patternKey SHORT_DATE_FORMAT * * @param dateTime * @see #getFormattedDateTime(Object, String, Locale, TimeZone) */ public String getFormattedDate(final Object date) { return getFormattedDate(date, ThreadLocalUserContext.getLocale(), ThreadLocalUserContext.getTimeZone()); }
/** * Gets the formatted time stamp with the context user's time zone and the internationalized pattern. * * @param dateTime * @param patternKey i18n key of the pattern */ public String getFormattedDateTime(final Date dateTime, final String pattern) { return getFormattedDateTime(dateTime, pattern, ThreadLocalUserContext.getLocale(), ThreadLocalUserContext.getTimeZone()); }
/** * Gets the formatted date (without time of day) with the context user's time zone and the internationalized pattern. * * @param date * @param patternKey i18n key of the pattern */ public String getFormattedDate(final Object date, final String pattern) { return getFormattedDate(date, pattern, ThreadLocalUserContext.getLocale(), ThreadLocalUserContext.getTimeZone()); }
private ICalParser() { this.parseVEvent = new ArrayList<>(); // set user, timezone, locale this.user = ThreadLocalUserContext.getUser(); this.timeZone = ThreadLocalUserContext.getTimeZone(); this.locale = ThreadLocalUserContext.getLocale(); this.reset(); }
private ICalGenerator() { this.exportsVEvent = new ArrayList<>(); // set user, timezone, locale this.user = ThreadLocalUserContext.getUser(); this.timeZone = ThreadLocalUserContext.getTimeZone(); this.locale = ThreadLocalUserContext.getLocale(); this.reset(); }
@BeforeClass public void setUp() { Calendar c = Calendar.getInstance(); c.setTimeZone(DateHelper.EUROPE_BERLIN); PowerMockito.mockStatic(ThreadLocalUserContext.class); PowerMockito.when(ThreadLocalUserContext.getTimeZone()).thenReturn(c.getTimeZone()); PowerMockito.when(ThreadLocalUserContext.getLocale()).thenReturn(Locale.ENGLISH); }
@BeforeMethod public void setUp() { Mockito.reset(teamEventDao); MockitoAnnotations.initMocks(this); mockStatic(ThreadLocalUserContext.class); mockStatic(ConfigXml.class); Locale locale = Locale.getDefault(); TimeZone timeZone = TimeZone.getDefault(); PowerMockito.when(ThreadLocalUserContext.getLocale()).thenReturn(locale); PowerMockito.when(ThreadLocalUserContext.getTimeZone()).thenReturn(timeZone); }
@BeforeMethod public void setUp() { MockitoAnnotations.initMocks(this); mockStatic(ThreadLocalUserContext.class); mockStatic(ConfigXml.class); ConfigXml configXml = new ConfigXml("./target/Projectforge"); PowerMockito.when(ThreadLocalUserContext.getLocale()).thenReturn(locale); PowerMockito.when(ThreadLocalUserContext.getTimeZone()).thenReturn(timeZone); PowerMockito.when(ConfigXml.getInstance()).thenReturn(configXml); systemService.setEnableVersionCheck(true); }
public VersionCheck getVersionCheckInformations() { Locale locale = ThreadLocalUserContext.getUser() != null && ThreadLocalUserContext.getUser().getLocale() != null ? ThreadLocalUserContext.getUser().getLocale() : ThreadLocalUserContext.getLocale(); TimeZone timeZone = ThreadLocalUserContext.getUser() != null && ThreadLocalUserContext.getUser().getTimeZone() != null ? TimeZone.getTimeZone(ThreadLocalUserContext.getUser().getTimeZone()) : ThreadLocalUserContext.getTimeZone(); VersionCheck versionCheck = new VersionCheck(AppVersion.VERSION.toString(), locale, timeZone); versionCheck = restCallService.callRestInterfaceForUrl(versionCheckUrl, HttpMethod.POST, VersionCheck.class, versionCheck); return versionCheck; }