Skip to content

Commit 85410e3

Browse files
Merge remote-tracking branch 'origin/master'
2 parents 428f340 + a79e7b7 commit 85410e3

53 files changed

Lines changed: 1154 additions & 306 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎core-java-8/pom.xml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@
6363
<scope>test</scope>
6464
</dependency>
6565

66+
<dependency>
67+
<groupId>org.assertj</groupId>
68+
<artifactId>assertj-core</artifactId>
69+
<version>3.4.1</version>
70+
</dependency>
71+
6672
<dependency>
6773
<groupId>org.mockito</groupId>
6874
<artifactId>mockito-core</artifactId>

‎core-java-8/src/main/java/com/baeldung/date_migration/NewApi.java‎

Lines changed: 0 additions & 54 deletions
This file was deleted.

‎core-java-8/src/main/java/com/baeldung/date_migration/OldApi.java‎

Lines changed: 0 additions & 68 deletions
This file was deleted.

core-java-8/src/main/java/com/baeldung/date_migration/Conversion.java renamed to core-java-8/src/test/java/com/baeldung/dateapi/ConversionExample.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.baeldung.date_migration;
1+
package com.baeldung.dateapi;
22

33
import java.time.Instant;
44
import java.time.ZoneId;
@@ -7,7 +7,7 @@
77
import java.util.GregorianCalendar;
88
import java.util.TimeZone;
99

10-
public class Conversion {
10+
public class ConversionExample {
1111
public static void main(String[] args) {
1212
Instant instantFromCalendar = GregorianCalendar.getInstance().toInstant();
1313
ZonedDateTime zonedDateTimeFromCalendar = new GregorianCalendar().toZonedDateTime();
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
package com.baeldung.dateapi;
2+
3+
import org.junit.Test;
4+
5+
import java.text.ParseException;
6+
import java.time.Duration;
7+
import java.time.LocalDate;
8+
import java.time.LocalDateTime;
9+
import java.time.LocalTime;
10+
import java.time.Month;
11+
import java.time.YearMonth;
12+
import java.time.format.DateTimeFormatter;
13+
import java.time.temporal.ChronoUnit;
14+
15+
import static org.assertj.core.api.Assertions.assertThat;
16+
17+
public class JavaUtilTimeTest {
18+
19+
@Test
20+
public void currentTime() {
21+
final LocalDate now = LocalDate.now();
22+
23+
System.out.println(now);
24+
// there is not much to test here
25+
}
26+
27+
@Test
28+
public void specificTime() {
29+
LocalDate birthDay = LocalDate.of(1990, Month.DECEMBER, 15);
30+
31+
System.out.println(birthDay);
32+
// there is not much to test here
33+
}
34+
35+
@Test
36+
public void extractMonth() {
37+
Month month = LocalDate.of(1990, Month.DECEMBER, 15).getMonth();
38+
39+
assertThat(month).isEqualTo(Month.DECEMBER);
40+
}
41+
42+
@Test
43+
public void subtractTime() {
44+
LocalDateTime fiveHoursBefore = LocalDateTime.of(1990, Month.DECEMBER, 15, 15, 0).minusHours(5);
45+
46+
assertThat(fiveHoursBefore.getHour()).isEqualTo(10);
47+
}
48+
49+
@Test
50+
public void alterField() {
51+
LocalDateTime inJune = LocalDateTime.of(1990, Month.DECEMBER, 15, 15, 0).with(Month.JUNE);
52+
53+
assertThat(inJune.getMonth()).isEqualTo(Month.JUNE);
54+
}
55+
56+
@Test
57+
public void truncate() {
58+
LocalTime truncated = LocalTime.of(15, 12, 34).truncatedTo(ChronoUnit.HOURS);
59+
60+
assertThat(truncated).isEqualTo(LocalTime.of(15, 0, 0));
61+
}
62+
63+
@Test
64+
public void getTimeSpan() {
65+
LocalDateTime now = LocalDateTime.now();
66+
LocalDateTime hourLater = now.plusHours(1);
67+
Duration span = Duration.between(now, hourLater);
68+
69+
assertThat(span).isEqualTo(Duration.ofHours(1));
70+
}
71+
72+
@Test
73+
public void formatAndParse() throws ParseException {
74+
LocalDate someDate = LocalDate.of(2016, 12, 7);
75+
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
76+
String formattedDate = someDate.format(formatter);
77+
LocalDate parsedDate = LocalDate.parse(formattedDate, formatter);
78+
79+
assertThat(formattedDate).isEqualTo("2016-12-07");
80+
assertThat(parsedDate).isEqualTo(someDate);
81+
}
82+
83+
@Test
84+
public void daysInMonth() {
85+
int daysInMonth = YearMonth.of(1990, 2).lengthOfMonth();
86+
87+
assertThat(daysInMonth).isEqualTo(28);
88+
}
89+
}

‎httpclient/README.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
=========
2-
32
## HttpClient 4.x Cookbooks and Examples
43

4+
###The Course
5+
The "REST With Spring" Classes: http://bit.ly/restwithspring
6+
57

68
### Relevant Articles:
79

‎jackson/README.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Jackson Cookbooks and Examples
44

5+
###The Course
6+
The "REST With Spring" Classes: http://bit.ly/restwithspring
7+
58
### Relevant Articles:
69
- [Jackson Ignore Properties on Marshalling](http://www.baeldung.com/jackson-ignore-properties-on-serialization)
710
- [Jackson – Unmarshall to Collection/Array](http://www.baeldung.com/jackson-collection-array)

‎mock-comparisons/pom.xml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
<mockito.version>1.10.19</mockito.version>
1313
<easymock.version>3.4</easymock.version>
1414
<jmockit.version>1.24</jmockit.version>
15+
16+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1517

1618
<!-- maven plugins -->
1719
<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>

‎raml/README.MD‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
###The Course
2+
The "REST With Spring" Classes: http://bit.ly/restwithspring

‎rest-testing/README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## REST Testing and Examples
44

5+
###The Course
6+
The "REST With Spring" Classes: http://bit.ly/restwithspring
57

68
### Relevant Articles:
79
- [Test a REST API with Java](http://www.baeldung.com/2011/10/13/integration-testing-a-rest-api/)

0 commit comments

Comments
 (0)