[BAEL-19059] - Move new articles to java-dates-operations module
This commit is contained in:
+19
@@ -0,0 +1,19 @@
|
||||
package com.baeldung.offsetdatetime;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.Date;
|
||||
|
||||
public class ConvertToOffsetDateTime {
|
||||
|
||||
public static OffsetDateTime convert(Date date) {
|
||||
return date.toInstant()
|
||||
.atOffset(ZoneOffset.UTC);
|
||||
}
|
||||
|
||||
public static OffsetDateTime convert(Date date, int hour, int minute) {
|
||||
return date.toInstant()
|
||||
.atOffset(ZoneOffset.ofHoursMinutes(hour, minute));
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.baeldung.datetime;
|
||||
package com.baeldung.skipweekends;
|
||||
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDate;
|
||||
+3
-3
@@ -1,13 +1,13 @@
|
||||
package com.baeldung.date.comparison;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Date;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class DateComparisonUtilsUnitTest {
|
||||
|
||||
|
||||
+2
-5
@@ -1,15 +1,12 @@
|
||||
package com.baeldung.datetime;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.baeldung.datetime.CalendarUtils;
|
||||
import com.baeldung.datetime.DateUtils;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class CalendarUtilsUnitTest {
|
||||
|
||||
@Test
|
||||
|
||||
+2
-4
@@ -1,14 +1,12 @@
|
||||
package com.baeldung.datetime;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.baeldung.datetime.DateUtils;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class DateUtilsUnitTest {
|
||||
|
||||
@Test
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.baeldung.offsetdatetime;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class ConvertToOffsetDateTimeUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenDateIsNotNull_thenConvertToOffsetDateTime() {
|
||||
Date date = new Date();
|
||||
assertTrue(ConvertToOffsetDateTime.convert(date) instanceof OffsetDateTime);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenDate_whenHasOffset_thenConvertWithOffset() {
|
||||
Date date = new Date();
|
||||
date.setHours(6);
|
||||
date.setMinutes(30);
|
||||
OffsetDateTime odt = ConvertToOffsetDateTime.convert(date, 3, 30);
|
||||
assertEquals(10, odt.getHour());
|
||||
assertEquals(0, odt.getMinute());
|
||||
}
|
||||
|
||||
}
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
package com.baeldung.datetime;
|
||||
package com.baeldung.skipweekends;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.baeldung.skipweekends.AddSubtractDaysSkippingWeekendsUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.time.LocalDate;
|
||||
Reference in New Issue
Block a user