@Test @PrepareForTest({TimeZoneUtils.class, DateTimeFormat.class}) public void testGetClientOffset() { final Date date = mock(Date.class); final TimeZone timeZone = mock(TimeZone.class); final int serverSideOffSet = -180; final int dateOffSet = -120; final int expectedOffset = -60; mockStatic(TimeZoneUtils.class); when(TimeZoneUtils.getTimeZone()).thenReturn(timeZone); when(TimeZoneUtils.getClientOffset(any(Date.class))).thenCallRealMethod(); when(timeZone.getStandardOffset()).thenReturn(serverSideOffSet); when(date.getTimezoneOffset()).thenReturn(dateOffSet); final int actualOffset = TimeZoneUtils.getClientOffset(date); assertEquals(expectedOffset, actualOffset); }
static int getClientOffset(final Date date) { final int standardOffset = getTimeZone().getStandardOffset(); final int timezoneOffset = date.getTimezoneOffset(); final int timeZoneOffsetInMinutes = standardOffset - (timezoneOffset * 2); return -timeZoneOffsetInMinutes; }
TimeZoneUtils { static int getClientOffset(final Date date) { final int standardOffset = getTimeZone().getStandardOffset(); final int timezoneOffset = date.getTimezoneOffset(); final int timeZoneOffsetInMinutes = standardOffset - (timezoneOffset * 2); return -timeZoneOffsetInMinutes; } }
TimeZoneUtils { static int getClientOffset(final Date date) { final int standardOffset = getTimeZone().getStandardOffset(); final int timezoneOffset = date.getTimezoneOffset(); final int timeZoneOffsetInMinutes = standardOffset - (timezoneOffset * 2); return -timeZoneOffsetInMinutes; }  }
TimeZoneUtils { static int getClientOffset(final Date date) { final int standardOffset = getTimeZone().getStandardOffset(); final int timezoneOffset = date.getTimezoneOffset(); final int timeZoneOffsetInMinutes = standardOffset - (timezoneOffset * 2); return -timeZoneOffsetInMinutes; }  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 { static int getClientOffset(final Date date) { final int standardOffset = getTimeZone().getStandardOffset(); final int timezoneOffset = date.getTimezoneOffset(); final int timeZoneOffsetInMinutes = standardOffset - (timezoneOffset * 2); return -timeZoneOffsetInMinutes; }  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; }