I have 2 Joda LocalDateTime LocalDateTime and you need to create a third one that represents the difference between them:
LocalDateTime start = getStartLocalDateTime(); LocalDateTime end = getEndLocalDateTime(); LocalDateTime diff = ???
The only way I can understand is to painstakingly go through each date / time field and perform its corresponding minus operation:
LocalDateTime diff = end; diff.minusYears(start.getYear()); diff.minusMonths(start.getMonthOfYear()); diff.minusDays(start.getDayOfMonth()); diff.minusHours(start.getHourOfDay()); diff.minusMinutes(start.getMinuteOfHour()); diff.minusSeconds(start.getSecondsOfMinute());
The end result would be to simply call the diff toString() method and get something meaningful. For example, if start.toString() produces 2012/02 / 08T15: 05: 00 and end.toString() produces 2012/02 / 08T16: 00: 00, then diff.toString() will be the difference (55 minutes) and might look like 2012/02 / 08T00: 55 :. 00
And if this is a terrible abuse of LocalDateTime , then I just need to know how to use the time difference between the two and split this difference into an easily readable (human-friendly) format.
Thanks in advance!
java jodatime
IAmYourFaja
source share