@Test @PrepareForTest({TimeZoneUtils.class, DateTimeFormat.class}) public void testConvertToServerTimeZone() { final Date date = mock(Date.class); final Date expectedDate = mock(Date.class); final TimeZone timeZone = mock(TimeZone.class); final ArgumentCaptor<TimeZone> captorTimeZone = ArgumentCaptor.forClass(TimeZone.class); final String convertedDate = "01-01-1900"; final DateTimeFormat internalFormat = mock(DateTimeFormat.class); final int expectedClientOffset = -60; mockStatic(TimeZoneUtils.class); when(TimeZoneUtils.getTimeZone()).thenReturn(timeZone); when(TimeZoneUtils.internalFormatter()).thenReturn(internalFormat); when(TimeZoneUtils.getClientOffset(date)).thenReturn(expectedClientOffset); when(TimeZoneUtils.convertToServerTimeZone(any(Date.class))).thenCallRealMethod(); when(internalFormat.format(eq(date), captorTimeZone.capture())).thenReturn(convertedDate); when(internalFormat.parse(convertedDate)).thenReturn(expectedDate); final Date actualDate = TimeZoneUtils.convertToServerTimeZone(date); assertEquals(expectedClientOffset, captorTimeZone.getValue().getStandardOffset()); assertEquals(expectedDate, actualDate); }
public static Date convertToServerTimeZone(final Date date) { final String convertedDate = internalFormatter().format(date, createTimeZone(getClientOffset(date))); return internalFormatter().parse(convertedDate); }
TimeZoneUtils { public static Date convertToServerTimeZone(final Date date) { final String convertedDate = internalFormatter().format(date, createTimeZone(getClientOffset(date))); return internalFormatter().parse(convertedDate); } }
TimeZoneUtils { public static Date convertToServerTimeZone(final Date date) { final String convertedDate = internalFormatter().format(date, createTimeZone(getClientOffset(date))); return internalFormatter().parse(convertedDate); }  }
TimeZoneUtils { public static Date convertToServerTimeZone(final Date date) { final String convertedDate = internalFormatter().format(date, createTimeZone(getClientOffset(date))); return internalFormatter().parse(convertedDate); }  static Date convertFromServerTimeZone(final Date date); static Date convertToServerTimeZone(final Date date); static String formatWithServerTimeZone(final Date date); static TimeZone getTimeZone(); static DateTimeFormat internalFormatter(); }
TimeZoneUtils { public static Date convertToServerTimeZone(final Date date) { final String convertedDate = internalFormatter().format(date, createTimeZone(getClientOffset(date))); return internalFormatter().parse(convertedDate); }  static Date convertFromServerTimeZone(final Date date); static Date convertToServerTimeZone(final Date date); static String formatWithServerTimeZone(final Date date); static TimeZone getTimeZone(); static DateTimeFormat internalFormatter(); final static DateTimeFormat FORMATTER; }