JodatimeUtils { public static DateTime parse(String source, String pattern){ Assert.hasText(source); return DateTimeFormat.forPattern(pattern).parseDateTime(source); } private  JodatimeUtils(); static DateTime atStartOfDate(Date date); static DateTime atStartOfDate(Date date, int plusDays); static DateTime atEndOfDate(Date date); static DateTime atEndOfDate(Date date, int plusDays); static DateTime atStartOfMonth(Date date); static DateTime atEndOfMonth(Date date); static String format(Date date, String pattern); static String formatDateTime(Date date); static DateTime parse(String source, String pattern); static DateTime parse(String source); static Interval createInterval(String start, String end); static Interval createInterval(Date start, Date end); static boolean isTimeBetweenInterval(Date theTime, Date start, Date end); static Period between(Date start, Date end); static Period between(LocalDateTime start, LocalDateTime end); static String[] DATE_PATTERNS; static String PATTERN_DATE_TIME; }
@Test public void testInterval(){ DateTime start = JodatimeUtils.parse("2016-11-24"); DateTime end = JodatimeUtils.parse("2016-12-24"); Interval interval = new Interval(start, end); boolean res = interval.contains(start.plusSeconds(1)); Assertions.assertThat(res).isTrue(); res = interval.contains(start.minusSeconds(1)); Assertions.assertThat(res).isFalse(); }