How to get last month/year in java?

Your solution is here but instead of addition you need to use subtraction c.add(Calendar.MONTH, -1); Then you can call getter on the Calendar to acquire proper fields int month = c.get(Calendar.MONTH) + 1; // beware of month indexing from zero int year = c.get(Calendar.YEAR);

What is the motivation for two different week-based-year definitions in JSR-310?

This is a bug in IsoFields which managed to slip through because this method was untested (sorry about that). There should be very little observable difference between IsoFields and WeekFields.ISO when implemented correctly. See the bug report and patch which will eventually work through the system and be fixed. Note, testing revealed that getting the … Read more

How to use java.time.ZonedDateTime / LocalDateTime in p:calendar

Your concrete problem is that you migrated from Joda’s zoneless date time instance DateTime to Java8’s zoned date time instance ZonedDateTime instead of Java8’s zoneless date time instance LocalDateTime. Using ZonedDateTime (or OffsetDateTime) instead of LocalDateTime requires at least 2 additional changes: Do not force a time zone (offset) during date time conversion. Instead, the … Read more

LocalDateTime to java.sql.Date in java 8?

There is no direct correlation between LocalDateTime and java.sql.Date, since former is-a timestamp, and latter is-a Date. There is, however, a relation between LocalDate and java.sql.Date, and conversion can be done like this: LocalDate date = //your local date java.sql.Date sqlDate = java.sql.Date.valueOf(date) Which for any given LocalDateTime gives you the following code: LocalDateTime dateTime … Read more

Java 8 LocalDate – How do I get all dates between two dates?

Assuming you mainly want to iterate over the date range, it would make sense to create a DateRange class that is iterable. That would allow you to write: for (LocalDate d : DateRange.between(startDate, endDate)) … Something like: public class DateRange implements Iterable<LocalDate> { private final LocalDate startDate; private final LocalDate endDate; public DateRange(LocalDate startDate, LocalDate … Read more