baeldung-articles : BAEL-7403 (#15573)
* baeldung-articles : BAEL-7403 Convert Joda-Time DateTime to Date and Vice Versa * (Move) baeldung-articles : BAEL-7403 Move the code to this module.
This commit is contained in:
parent
5136e7349b
commit
a94bf971f5
@ -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());
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user