Skip to content

Commit d5e91a8

Browse files
author
Antonio Moreno
committed
Revert "BAEL-2522 - Reverting changes"
This reverts commit bac1103.
1 parent bac1103 commit d5e91a8

File tree

4 files changed

+119
-0
lines changed

4 files changed

+119
-0
lines changed

java-dates-2/.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
*.class
2+
3+
0.*
4+
5+
#folders#
6+
/target
7+
/neoDb*
8+
/data
9+
/src/main/webapp/WEB-INF/classes
10+
*/META-INF/*
11+
.resourceCache
12+
13+
# Packaged files #
14+
*.jar
15+
*.war
16+
*.ear
17+
18+
# Files generated by integration tests
19+
*.txt
20+
backup-pom.xml
21+
/bin/
22+
/temp
23+
24+
#IntelliJ specific
25+
.idea/
26+
*.iml
27+
28+
#jenv
29+
.java-version

java-dates-2/pom.xml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.baeldung</groupId>
5+
<artifactId>java-dates-2</artifactId>
6+
<version>0.1.0-SNAPSHOT</version>
7+
<packaging>jar</packaging>
8+
<name>java-dates-2</name>
9+
10+
<parent>
11+
<groupId>com.baeldung</groupId>
12+
<artifactId>parent-java</artifactId>
13+
<version>0.0.1-SNAPSHOT</version>
14+
<relativePath>../parent-java</relativePath>
15+
</parent>
16+
17+
<dependencies>
18+
<!-- test scoped -->
19+
<dependency>
20+
<groupId>org.assertj</groupId>
21+
<artifactId>assertj-core</artifactId>
22+
<version>${assertj.version}</version>
23+
<scope>test</scope>
24+
</dependency>
25+
</dependencies>
26+
27+
<build>
28+
<finalName>java-dates-2</finalName>
29+
<resources>
30+
<resource>
31+
<directory>src/main/resources</directory>
32+
<filtering>true</filtering>
33+
</resource>
34+
</resources>
35+
36+
<plugins>
37+
<plugin>
38+
<groupId>org.apache.maven.plugins</groupId>
39+
<artifactId>maven-compiler-plugin</artifactId>
40+
<version>${maven-compiler-plugin.version}</version>
41+
<configuration>
42+
<source>${maven.compiler.source}</source>
43+
<target>${maven.compiler.target}</target>
44+
</configuration>
45+
</plugin>
46+
</plugins>
47+
</build>
48+
49+
<properties>
50+
<!-- testing -->
51+
<assertj.version>3.6.1</assertj.version>
52+
<maven.compiler.source>1.9</maven.compiler.source>
53+
<maven.compiler.target>1.9</maven.compiler.target>
54+
</properties>
55+
</project>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.baeldung.xmlgregoriancalendar;
2+
3+
import org.junit.Test;
4+
5+
import javax.xml.datatype.DatatypeConfigurationException;
6+
import javax.xml.datatype.DatatypeFactory;
7+
import javax.xml.datatype.XMLGregorianCalendar;
8+
import java.time.LocalDate;
9+
10+
import static org.assertj.core.api.Assertions.assertThat;
11+
12+
public class XmlGregorianCalendarConverterUnitTest {
13+
14+
@Test
15+
public void fromLocalDateToXMLGregorianCalendar() throws DatatypeConfigurationException {
16+
LocalDate localDate = LocalDate.of(2017, 4, 25);
17+
XMLGregorianCalendar xmlGregorianCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(localDate.toString());
18+
19+
assertThat(xmlGregorianCalendar.getYear()).isEqualTo(localDate.getYear());
20+
assertThat(xmlGregorianCalendar.getMonth()).isEqualTo(localDate.getMonthValue());
21+
assertThat(xmlGregorianCalendar.getDay()).isEqualTo(localDate.getDayOfMonth());
22+
}
23+
24+
@Test
25+
public void fromXMLGregorianCalendarToLocalDate() throws DatatypeConfigurationException {
26+
XMLGregorianCalendar xmlGregorianCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar("2017-04-25");
27+
LocalDate localDate = LocalDate.of(xmlGregorianCalendar.getYear(), xmlGregorianCalendar.getMonth(), xmlGregorianCalendar.getDay());
28+
29+
assertThat(localDate.getYear()).isEqualTo(xmlGregorianCalendar.getYear());
30+
assertThat(localDate.getMonthValue()).isEqualTo(xmlGregorianCalendar.getMonth());
31+
assertThat(localDate.getDayOfMonth()).isEqualTo(xmlGregorianCalendar.getDay());
32+
}
33+
34+
}

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@
440440
<module>java-collections-conversions</module>
441441
<module>java-collections-maps</module>
442442
<!-- <module>java-dates</module> --> <!-- We haven't upgraded to java 9. Fixing in BAEL-10841 -->
443+
<module>java-dates-2</module>
443444
<!-- <module>java-ee-8-security-api</module> --> <!-- long running -->
444445
<module>java-lite</module>
445446
<module>java-numbers</module>

0 commit comments

Comments
 (0)