Now suppose I want to print out the date of the last day of the week of the month after the one that is 45 days from Y2K. Frankly, I don't even want to try tackling this using
Calendar
. It's just too painful to use the JDK to do even a simple date calculation like this one. It was at such a moment a few years ago when I first realized the power of Joda-Time. Using Joda, the code for the calculation looks like Listing 3:
DateTime dateTime = new DateTime(2000, 1, 1, 0, 0, 0, 0);
System.out.println(dateTime.plusDays(45).plusMonths(1).dayOfWeek()
.withMaximumValue().toString("E MM/dd/yyyy HH:mm:ss.SSS");
В общем, стоит попробовать.
Комментариев нет:
Отправить комментарий