diff --git a/core-java-modules/core-java-datetime-conversion/src/test/java/com/baeldung/jodadatetimetostandarddate/JodaDateTimeToDateAndViceVersaUnitTest.java b/core-java-modules/core-java-datetime-conversion/src/test/java/com/baeldung/jodadatetimetostandarddate/JodaDateTimeToDateAndViceVersaUnitTest.java new file mode 100644 index 0000000000..e84dfff3ef --- /dev/null +++ b/core-java-modules/core-java-datetime-conversion/src/test/java/com/baeldung/jodadatetimetostandarddate/JodaDateTimeToDateAndViceVersaUnitTest.java @@ -0,0 +1,22 @@ +package com.baeldung.jodadatetimetostandarddate; + +import org.joda.time.DateTime; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class JodaDateTimeToDateAndViceVersaUnitTest { + @Test + public void givenJodaDateTime_whenConvertingToJavaDate_thenConversionIsCorrect() { + DateTime jodaDateTime = new DateTime(); + java.util.Date javaDate = jodaDateTime.toDate(); + assertEquals(jodaDateTime, new DateTime(javaDate)); + } + + @Test + public void givenJavaDate_whenConvertingToJodaDateTime_thenConversionIsCorrect() { + java.util.Date javaDate = new java.util.Date(); + DateTime jodaDateTime = new DateTime(javaDate); + assertEquals(javaDate, jodaDateTime.toDate()); + } +}