Merge pull request #9105 from Maiklins/JAVA-617

Java-617
This commit is contained in:
Josh Cummings 2020-04-18 23:09:49 -06:00 committed by GitHub
commit 8a4c2d112e
45 changed files with 20 additions and 18 deletions

View File

@ -0,0 +1,5 @@
### Relevant Articles:
- [Generating Random Dates in Java](https://www.baeldung.com/java-random-dates)
- [Creating a LocalDate with Values in Java](https://www.baeldung.com/java-creating-localdate-with-values)
- [[<-- Prev]](/core-java-modules/core-java-datetime-java8-1)

View File

@ -4,9 +4,9 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-datetime-java8</artifactId>
<artifactId>core-java-8-datetime</artifactId>
<version>${project.parent.version}</version>
<name>core-java-datetime-java8</name>
<name>core-java-8-datetime</name>
<packaging>jar</packaging>
<parent>
@ -64,8 +64,8 @@
</build>
<properties>
<maven.compiler.source>1.9</maven.compiler.source>
<maven.compiler.target>1.9</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<joda-time.version>2.10</joda-time.version>
<!-- testing -->
<assertj.version>3.6.1</assertj.version>

View File

@ -11,31 +11,31 @@ public class LocalDateExampleUnitTest {
@Test
public void givenValues_whenUsingOfMethod_thenLocalDate() {
assertEquals("2020-01-08", date.getCustomDateOne(2020, 1, 8));
assertEquals("2020-01-08", date.getCustomDateOne(2020, 1, 8).toString());
}
@Test
public void givenValuesWithMonthEnum_whenUsingOfMethod_thenLocalDate() {
assertEquals("2020-01-08", date.getCustomDateTwo(2020, Month.JANUARY, 8));
assertEquals("2020-01-08", date.getCustomDateTwo(2020, Month.JANUARY, 8).toString());
}
@Test
public void givenValues_whenUsingEpochDay_thenLocalDate() {
assertEquals("2020-01-08", date.getDateFromEpochDay(18269));
assertEquals("2020-01-08", date.getDateFromEpochDay(18269).toString());
}
@Test
public void givenValues_whenUsingYearDay_thenLocalDate() {
assertEquals("2020-01-08", date.getDateFromYearAndDayOfYear(2020, 8));
assertEquals("2020-01-08", date.getDateFromYearAndDayOfYear(2020, 8).toString());
}
@Test
public void givenValues_whenUsingParse_thenLocalDate() {
assertEquals("2020-01-08", date.getDateFromString("2020-01-08"));
assertEquals("2020-01-08", date.getDateFromString("2020-01-08").toString());
}
@Test
public void givenValuesWithFormatter_whenUsingParse_thenLocalDate() {
assertEquals("2020-01-08", date.getDateFromStringAndFormatter("8-Jan-2020", "d-MMM-yyyy"));
assertEquals("2020-01-08", date.getDateFromStringAndFormatter("8-Jan-2020", "d-MMM-yyyy").toString());
}
}

View File

@ -13,4 +13,4 @@ This module contains articles about the Date and Time API introduced with Java 8
- [How to Get the Start and the End of a Day using Java](http://www.baeldung.com/java-day-start-end)
- [Set the Time Zone of a Date in Java](https://www.baeldung.com/java-set-date-time-zone)
- [Comparing Dates in Java](https://www.baeldung.com/java-comparing-dates)
- [Generating Random Dates in Java](https://www.baeldung.com/java-random-dates)
- [[Next -->]](/core-java-modules/core-java-datetime-java8-2)

View File

@ -4,9 +4,9 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-datetime-java8</artifactId>
<artifactId>core-java-8-datetime</artifactId>
<version>${project.parent.version}</version>
<name>core-java-datetime-java8</name>
<name>core-java-8-datetime</name>
<packaging>jar</packaging>
<parent>
@ -64,8 +64,8 @@
</build>
<properties>
<maven.compiler.source>1.9</maven.compiler.source>
<maven.compiler.target>1.9</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<joda-time.version>2.10</joda-time.version>
<!-- testing -->
<assertj.version>3.6.1</assertj.version>

View File

@ -1,3 +0,0 @@
### Relevant Articles:
- [Creating a LocalDate with Values in Java](https://www.baeldung.com/java-creating-localdate-with-values)