DateTimeUtils { public static LocalDateTime skipDaylightSavingGapIfExists(LocalDateTime date) { final DateTimeZone dtz = DateTimeZone.getDefault(); if (dtz != null) { while (dtz.isLocalDateTimeGap(date)) { date = date.plusMinutes(1); } } return date; } private  DateTimeUtils(); static String getDateTimeLabel(Date date, DatePickerDetails datePickerDetails, boolean containsTime, Context context); static LocalDateTime skipDaylightSavingGapIfExists(LocalDateTime date); static DatePickerDetails getDatePickerDetails(String appearance); static long tsToSec8601(String timestamp); static String formatDateFromServer(String time); static String getRelativeTime(String dateTime, Boolean dateTimeFromServer); static String getFormattedDate(String format, long time);  }
@Test public void skipDaylightSavingGapIfExistsTest() { DateTimeZone originalDefaultTimeZone = DateTimeZone.getDefault(); DateTimeZone.setDefault(DateTimeZone.forTimeZone(TimeZone.getTimeZone("Africa/Nairobi"))); LocalDateTime ldtOriginal = new LocalDateTime().withYear(1960).withMonthOfYear(1).withDayOfMonth(1).withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0); LocalDateTime ldtExpected = new LocalDateTime().withYear(1960).withMonthOfYear(1).withDayOfMonth(1).withHourOfDay(0).withMinuteOfHour(15).withSecondOfMinute(0).withMillisOfSecond(0); assertEquals(ldtExpected, DateTimeUtils.skipDaylightSavingGapIfExists(ldtOriginal)); DateTimeZone.setDefault(originalDefaultTimeZone); }