Split the first 2 modules: java-dates-conversion and java-dates-string.

This commit is contained in:
Alessio Stalla
2019-09-17 19:13:21 +02:00
parent 9154f5e062
commit ed9463faa1
62 changed files with 158 additions and 48 deletions

View File

@@ -1,4 +0,0 @@
## Relevant Articles:
- [Converting Between LocalDate and XMLGregorianCalendar](https://www.baeldung.com/java-localdate-to-xmlgregoriancalendar)
- [Convert Time to Milliseconds in Java](https://www.baeldung.com/java-time-milliseconds)
- [Check If a String Is a Valid Date in Java](https://www.baeldung.com/java-string-valid-date)

View File

@@ -23,7 +23,4 @@ backup-pom.xml
#IntelliJ specific #IntelliJ specific
.idea/ .idea/
*.iml *.iml
#jenv
.java-version

View File

@@ -0,0 +1,9 @@
=========
## Java Date/time conversion Cookbooks and Examples
### Relevant Articles:
- [Converting Between LocalDate and XMLGregorianCalendar](https://www.baeldung.com/java-localdate-to-xmlgregoriancalendar)
- [Convert Time to Milliseconds in Java](https://www.baeldung.com/java-time-milliseconds)
- [Convert Date to LocalDate or LocalDateTime and Back](http://www.baeldung.com/java-date-to-localdate-and-localdatetime)
- [Convert Between java.time.Instant and java.sql.Timestamp](https://www.baeldung.com/java-time-instant-to-java-sql-timestamp)

View File

@@ -1,11 +1,10 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" 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"> 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> <modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId> <artifactId>java-dates-conversion</artifactId>
<artifactId>java-dates-2</artifactId> <version>${project.parent.version}</version>
<version>0.1.0-SNAPSHOT</version> <name>java-dates</name>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>java-dates-2</name>
<parent> <parent>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
@@ -20,14 +19,16 @@
<artifactId>joda-time</artifactId> <artifactId>joda-time</artifactId>
<version>${joda-time.version}</version> <version>${joda-time.version}</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/commons-validator/commons-validator -->
<dependency> <dependency>
<groupId>commons-validator</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-validator</artifactId> <artifactId>commons-lang3</artifactId>
<version>${commons-validator.version}</version> <version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency> </dependency>
<!-- test scoped --> <!-- test scoped -->
<dependency> <dependency>
<groupId>org.assertj</groupId> <groupId>org.assertj</groupId>
@@ -38,7 +39,7 @@
</dependencies> </dependencies>
<build> <build>
<finalName>java-dates-2</finalName> <finalName>java-dates</finalName>
<resources> <resources>
<resource> <resource>
<directory>src/main/resources</directory> <directory>src/main/resources</directory>
@@ -60,11 +61,10 @@
</build> </build>
<properties> <properties>
<joda-time.version>2.10</joda-time.version>
<!-- testing --> <!-- testing -->
<assertj.version>3.6.1</assertj.version> <assertj.version>3.6.1</assertj.version>
<joda-time.version>2.10</joda-time.version> <maven.compiler.source>1.9</maven.compiler.source>
<commons-validator.version>1.6</commons-validator.version>
<maven.compiler.source>1.9</maven.compiler.source>
<maven.compiler.target>1.9</maven.compiler.target> <maven.compiler.target>1.9</maven.compiler.target>
</properties> </properties>
</project> </project>

View File

@@ -1,15 +1,14 @@
package com.baeldung.datetime; package com.baeldung.datetime;
import static org.assertj.core.api.Assertions.assertThat; import org.junit.Test;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.Instant; import java.time.Instant;
import java.time.ZoneId;
import java.util.TimeZone; import java.util.TimeZone;
import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat;
public class ConvertInstantToTimestampUnitTest { public class ConvertInstantToTimestampUnitTest {

26
java-dates-string/.gitignore vendored Normal file
View File

@@ -0,0 +1,26 @@
*.class
0.*
#folders#
/target
/neoDb*
/data
/src/main/webapp/WEB-INF/classes
*/META-INF/*
.resourceCache
# Packaged files #
*.jar
*.war
*.ear
# Files generated by integration tests
*.txt
backup-pom.xml
/bin/
/temp
#IntelliJ specific
.idea/
*.iml

View File

@@ -0,0 +1,12 @@
=========
## Java Dates Parsing and Formatting Cookbooks and Examples
### Relevant Articles:
- [Check If a String Is a Valid Date in Java](https://www.baeldung.com/java-string-valid-date)
- [RegEx for matching Date Pattern in Java](http://www.baeldung.com/java-date-regular-expressions)
- [Guide to DateTimeFormatter](https://www.baeldung.com/java-datetimeformatter)
- [Format ZonedDateTime to String](https://www.baeldung.com/java-format-zoned-datetime-string)
- [A Guide to SimpleDateFormat](https://www.baeldung.com/java-simple-date-format)
- [Display All Time Zones With GMT And UTC in Java](http://www.baeldung.com/java-time-zones)
- [Convert between String and Timestamp](https://www.baeldung.com/java-string-to-timestamp)

83
java-dates-string/pom.xml Normal file
View File

@@ -0,0 +1,83 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" 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>java-dates-string</artifactId>
<version>${project.parent.version}</version>
<name>java-dates</name>
<packaging>jar</packaging>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-java</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../parent-java</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-validator/commons-validator -->
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>${commons-validator.version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<!-- test scoped -->
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${joda-time.version}</version>
</dependency>
<dependency>
<groupId>com.darwinsys</groupId>
<artifactId>hirondelle-date4j</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>java-dates</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<commons-validator.version>1.6</commons-validator.version>
<joda-time.version>2.10</joda-time.version>
<!-- testing -->
<assertj.version>3.6.1</assertj.version>
<maven.compiler.source>1.9</maven.compiler.source>
<maven.compiler.target>1.9</maven.compiler.target>
</properties>
</project>

View File

@@ -1,4 +1,4 @@
package com.baeldung.zoneddatetime; package com.baeldung.zonedatetime;
import java.time.OffsetDateTime; import java.time.OffsetDateTime;
import java.time.ZoneOffset; import java.time.ZoneOffset;

View File

@@ -1,4 +1,4 @@
package com.baeldung.zoneddatetime; package com.baeldung.zonedatetime;
import java.time.OffsetTime; import java.time.OffsetTime;
import java.time.ZoneOffset; import java.time.ZoneOffset;

View File

@@ -1,4 +1,4 @@
package com.baeldung.zoneddatetime; package com.baeldung.zonedatetime;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;

View File

@@ -1,4 +1,4 @@
package com.baeldung.zoneddatetime; package com.baeldung.zonedatetime;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;

View File

@@ -1,4 +1,4 @@
package com.baeldung.zoneddatetime; package com.baeldung.zonedatetime;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;

View File

@@ -1,4 +1,4 @@
package com.baeldung.zoneddatetime; package com.baeldung.zonedatetime;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;

View File

@@ -1,4 +1,4 @@
package com.baeldung.zoneddatetime; package com.baeldung.zonedatetime;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertThrows;

View File

@@ -7,14 +7,11 @@
- [Handling Daylight Savings Time in Java](http://www.baeldung.com/java-daylight-savings) - [Handling Daylight Savings Time in Java](http://www.baeldung.com/java-daylight-savings)
- [Period and Duration in Java](http://www.baeldung.com/java-period-duration) - [Period and Duration in Java](http://www.baeldung.com/java-period-duration)
- [Difference Between Two Dates in Java](http://www.baeldung.com/java-date-difference) - [Difference Between Two Dates in Java](http://www.baeldung.com/java-date-difference)
- [RegEx for matching Date Pattern in Java](http://www.baeldung.com/java-date-regular-expressions)
- [Migrating to the New Java 8 Date Time API](http://www.baeldung.com/migrating-to-java-8-date-time-api) - [Migrating to the New Java 8 Date Time API](http://www.baeldung.com/migrating-to-java-8-date-time-api)
- [Introduction to the Java 8 Date/Time API](http://www.baeldung.com/java-8-date-time-intro) - [Introduction to the Java 8 Date/Time API](http://www.baeldung.com/java-8-date-time-intro)
- [Get the Current Date, Time and Timestamp in Java 8](http://www.baeldung.com/current-date-time-and-timestamp-in-java-8) - [Get the Current Date, Time and Timestamp in Java 8](http://www.baeldung.com/current-date-time-and-timestamp-in-java-8)
- [Get Date Without Time in Java](http://www.baeldung.com/java-date-without-time) - [Get Date Without Time in Java](http://www.baeldung.com/java-date-without-time)
- [How to Get All Dates Between Two Dates?](http://www.baeldung.com/java-between-dates) - [How to Get All Dates Between Two Dates?](http://www.baeldung.com/java-between-dates)
- [Convert Date to LocalDate or LocalDateTime and Back](http://www.baeldung.com/java-date-to-localdate-and-localdatetime)
- [Display All Time Zones With GMT And UTC in Java](http://www.baeldung.com/java-time-zones)
- [Extracting Year, Month and Day from Date in Java](http://www.baeldung.com/java-year-month-day) - [Extracting Year, Month and Day from Date in Java](http://www.baeldung.com/java-year-month-day)
- [Guide to java.util.GregorianCalendar](http://www.baeldung.com/java-gregorian-calendar) - [Guide to java.util.GregorianCalendar](http://www.baeldung.com/java-gregorian-calendar)
- [Measure Elapsed Time in Java](http://www.baeldung.com/java-measure-elapsed-time) - [Measure Elapsed Time in Java](http://www.baeldung.com/java-measure-elapsed-time)
@@ -22,11 +19,6 @@
- [Calculate Age in Java](http://www.baeldung.com/java-get-age) - [Calculate Age in Java](http://www.baeldung.com/java-get-age)
- [Increment Date in Java](http://www.baeldung.com/java-increment-date) - [Increment Date in Java](http://www.baeldung.com/java-increment-date)
- [Add Hours To a Date In Java](http://www.baeldung.com/java-add-hours-date) - [Add Hours To a Date In Java](http://www.baeldung.com/java-add-hours-date)
- [Guide to DateTimeFormatter](https://www.baeldung.com/java-datetimeformatter)
- [Format ZonedDateTime to String](https://www.baeldung.com/java-format-zoned-datetime-string)
- [Convert Between java.time.Instant and java.sql.Timestamp](https://www.baeldung.com/java-time-instant-to-java-sql-timestamp)
- [Convert between String and Timestamp](https://www.baeldung.com/java-string-to-timestamp)
- [A Guide to SimpleDateFormat](https://www.baeldung.com/java-simple-date-format)
- [ZoneOffset in Java](https://www.baeldung.com/java-zone-offset) - [ZoneOffset in Java](https://www.baeldung.com/java-zone-offset)
- [Differences Between ZonedDateTime and OffsetDateTime](https://www.baeldung.com/java-zoneddatetime-offsetdatetime) - [Differences Between ZonedDateTime and OffsetDateTime](https://www.baeldung.com/java-zoneddatetime-offsetdatetime)
- [Introduction to Joda-Time](http://www.baeldung.com/joda-time) - [Introduction to Joda-Time](http://www.baeldung.com/joda-time)

View File

@@ -25,12 +25,6 @@
<artifactId>log4j</artifactId> <artifactId>log4j</artifactId>
<version>${log4j.version}</version> <version>${log4j.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<!-- test scoped --> <!-- test scoped -->
<dependency> <dependency>
<groupId>org.assertj</groupId> <groupId>org.assertj</groupId>

View File

@@ -467,8 +467,10 @@
<module>java-collections-maps</module> <module>java-collections-maps</module>
<module>java-collections-maps-2</module> <module>java-collections-maps-2</module>
<module>java-jdi</module> <module>java-jdi</module>
<!-- <module>java-dates</module> --> <!-- We haven't upgraded to java 9. Fixing in BAEL-10841 --> <!-- <module>java-dates</module>
<!-- <module>java-dates-2</module> --> <!-- We haven't upgraded to java 9. Fixing in BAEL-10841 --> <module>java-dates</module>
<module>java-dates-conversion</module>
<module>java-dates-string</module> --> <!-- We haven't upgraded to java 9. Fixing in BAEL-10841 -->
<!-- <module>java-ee-8-security-api</module> --> <!-- long running --> <!-- <module>java-ee-8-security-api</module> --> <!-- long running -->
<module>java-lite</module> <module>java-lite</module>
<module>java-math</module> <module>java-math</module>