@Test public void saneNowPlusDurationForAlarms() { DateTimeZone.setDefault(DateTimeZone.forID("America/Los_Angeles")); DateTimeUtils.setCurrentMillisFixed(LocalDateTime.parse("2018-03-11T01:34:00") .toDateTime(DateTimeZone.getDefault()).getMillis()); Assert.assertEquals(LocalDateTime.parse("2018-03-11T03:04:00"), Utils.saneNowPlusDurationForAlarms(Duration.standardMinutes(30))); DateTimeUtils.setCurrentMillisOffset(0L); }
public static LocalDateTime saneNowPlusDurationForAlarms(Duration duration) { LocalDateTime proposedLDT = Utils.getNow().plus(duration) .withSecondOfMinute(0) .withMillisOfSecond(0); while (DateTimeZone.getDefault().isLocalDateTimeGap(proposedLDT)) { proposedLDT = proposedLDT.plusMinutes(30); } return proposedLDT; }
Utils { public static LocalDateTime saneNowPlusDurationForAlarms(Duration duration) { LocalDateTime proposedLDT = Utils.getNow().plus(duration) .withSecondOfMinute(0) .withMillisOfSecond(0); while (DateTimeZone.getDefault().isLocalDateTimeGap(proposedLDT)) { proposedLDT = proposedLDT.plusMinutes(30); } return proposedLDT; } }
Utils { public static LocalDateTime saneNowPlusDurationForAlarms(Duration duration) { LocalDateTime proposedLDT = Utils.getNow().plus(duration) .withSecondOfMinute(0) .withMillisOfSecond(0); while (DateTimeZone.getDefault().isLocalDateTimeGap(proposedLDT)) { proposedLDT = proposedLDT.plusMinutes(30); } return proposedLDT; }  }
Utils { public static LocalDateTime saneNowPlusDurationForAlarms(Duration duration) { LocalDateTime proposedLDT = Utils.getNow().plus(duration) .withSecondOfMinute(0) .withMillisOfSecond(0); while (DateTimeZone.getDefault().isLocalDateTimeGap(proposedLDT)) { proposedLDT = proposedLDT.plusMinutes(30); } return proposedLDT; }  static LocalDateTime getNow(); static int getAppSmallIcon(); static DatePickerDialog getDatePickerDialog(Context context, DatePickerDialog.OnDateSetListener onDateSetListener, int year, int month, int day); static TimePickerDialog getTimePickerDialog(Context context,
                                                       TimePickerDialog.OnTimeSetListener onTimeSetListener,
                                                       int hour, int minute, boolean is24HourFormat); static void toastTo(final String toastMessage); static PendingIntent getPIInNewStack(Intent intent, int requestCode); static PendingIntent getPIInNewStack(Intent intent, int requestCode, int flags); static int calculateDaysUntil(LocalDateTime until); static String getFormattedMessageForDate(LocalDateTime localDateTime,
                                                    @StringRes int stringRed); static int getSharedUniqueId(); static LocalDateTime saneNowPlusDurationForAlarms(Duration duration); static DateTime convertLocalToDTSafely(LocalDateTime localDateTime); }
Utils { public static LocalDateTime saneNowPlusDurationForAlarms(Duration duration) { LocalDateTime proposedLDT = Utils.getNow().plus(duration) .withSecondOfMinute(0) .withMillisOfSecond(0); while (DateTimeZone.getDefault().isLocalDateTimeGap(proposedLDT)) { proposedLDT = proposedLDT.plusMinutes(30); } return proposedLDT; }  static LocalDateTime getNow(); static int getAppSmallIcon(); static DatePickerDialog getDatePickerDialog(Context context, DatePickerDialog.OnDateSetListener onDateSetListener, int year, int month, int day); static TimePickerDialog getTimePickerDialog(Context context,
                                                       TimePickerDialog.OnTimeSetListener onTimeSetListener,
                                                       int hour, int minute, boolean is24HourFormat); static void toastTo(final String toastMessage); static PendingIntent getPIInNewStack(Intent intent, int requestCode); static PendingIntent getPIInNewStack(Intent intent, int requestCode, int flags); static int calculateDaysUntil(LocalDateTime until); static String getFormattedMessageForDate(LocalDateTime localDateTime,
                                                    @StringRes int stringRed); static int getSharedUniqueId(); static LocalDateTime saneNowPlusDurationForAlarms(Duration duration); static DateTime convertLocalToDTSafely(LocalDateTime localDateTime);  }