Top "Java-time" questions

The java.

Differences between Java 8 Date Time API (java.time) and Joda-Time

I know there are questions relating to java.util.Date and Joda-Time. But after some digging, I couldn't find a …

java datetime java-8 jodatime java-time
Convert between LocalDate and sql.Date

What's the correct way to convert between java.sql.Date and LocalDate (Java8)?

java date java-8 converter java-time
Format a date using the new date time API

I was playing with the new date time API but when running this: public class Test { public static void main(…

java datetime java-8 java-time
Java8 java.util.Date conversion to java.time.ZonedDateTime

I am getting the following exception while trying to convert java.util.Date to java.time.LocalDate. java.time.DateTimeException: …

java date datetime java-8 java-time
Mocking time in Java 8's java.time API

Joda Time has a nice DateTimeUtils.setCurrentMillisFixed() to mock time. It's very practical in tests. Is there an equivalent in …

java datetime mocking java-8 java-time
Convert between LocalDate and XMLGregorianCalendar

What's the best way to convert between LocalDate from Java 8 and XMLGregorianCalendar?

java java-8 converter java-time
Why can't I get a duration in minutes or hours in java.time?

Of the Duration class in the new JSR 310 date API (java.time package) available in Java 8 and later, the javadoc …

java java-8 java-time
Is there any way to convert ZoneId to ZoneOffset in java 8?

I have an epoch second and a zoneId,by method1.It can be convert to LocalDateTime with system default zoneId,…

java java-8 java-time zoneddatetime java.time.instant
Unit testing a class with a Java 8 Clock

Java 8 introduced java.time.Clock which can be used as an argument to many other java.time objects, allowing you …

java unit-testing java-8 java-time
How to format a ZonedDateTime to a String?

I want to convert a ZonedDateTime to a String in the format of ("dd/MM/yyyy - hh:mm"). I …

java string java-time zoneddatetime