Joda-Time, as said in its website, "provides a quality replacement for the Java date and time classes". It contains lots of classes to work with dates, times, timezones and an integration with Hibernate among other functionalities.
op4j-jodatime is an extension that gives you access to a bunch of functions related to jodatime classes in an op4j way. The functions in this extension include:
The extension comprises the following function hub class:
List<DateTime> targets = new ArrayList<DateTime>(); targets.add(new DateTime()); List<String> result1 = Op.onList(targets).forEach().exec(FnJodaString.baseDateTimeToStr(FormatType.PATTERN, "yyyy-MM-DD_HH:mm:ss:SS")).get(); String pattern = "dd/mm/yyyy-HH:mm"; String asStr = "24/12/2000-15:03"; DateMidnight result2 = Op.on(asStr).exec(FnDateMidnight.strToDateMidnight(pattern)).get();
is equivalent to
List<DateTime> targets = new ArrayList<DateTime>(); targets.add(new DateTime()); List<String> result1 = Op.onList(targets).forEach().exec(FnJodaTimeUtils.baseDateTimeToStr(FormatType.PATTERN, "yyyy-MM-DD_HH:mm:ss:SS")).get(); String pattern = "dd/mm/yyyy-HH:mm"; String asStr = "24/12/2000-15:03"; DateMidnight result2 = Op.on(asStr).exec(FnJodaTimeUtils.strToDateMidnight(pattern)).get();
This section includes some examples of the use of the classes listed above. To learn about the methods available, visit the pages:
List<DateMidnight> targets = new ArrayList<DateMidnight>(); targets.add(new DateMidnight()); List<String> result = Op.onList(targets).forEach().exec(FnJodaString .baseDateTimeToStr(FormatType.STYLE, "MM", Locale.UK.toString())).get(); /* *** */ Timestamp timestamp = new Timestamp(new Date().getTime()); LocalTime result = Op.on(timestamp).exec(FnLocalTime.timestampToLocalTime( DateTimeZone.getDefault())).get(); /* *** */ Interval result = Op.on(Arrays.asList("1977", "5", "2", "23", "12", "2", "34", "1980", "8", "5", "12", "12", "12", "4")) .exec(FnInterval.strFieldCollectionToInterval(DateTimeZone.getDefault())) .get(); /* *** */ Interval result = Op.on(Arrays.asList("2000/02/09", "2001/09/05")) .exec(FnInterval.strFieldCollectionToInterval("yyyy/mm/dd", DateTimeZone.getDefault())).get(); /* *** */ Long start = Long.valueOf(1000); Long end = Long.valueOf(1000000); Interval result = Op.on(new Long[] {start, end}) .exec(FnInterval.longFieldArrayToInterval(GJChronology.getInstance())) .get();