Skip to content

Commit 7e8f8d1

Browse files
committed
Mention locales in DateTime concept
This updates the date time concept to mention different Locales can be used with the DateTimeFormatter. Locales is needed to solve the corresponding Booking for Beauty exercise, so it would be helpful for students to be aware of this. Resolves #3088
1 parent 9b6bb42 commit 7e8f8d1

4 files changed

Lines changed: 37 additions & 2 deletions

File tree

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{
22
"blurb": "There are several classes in Java to work with dates and time.",
3-
"authors": ["sanderploegsma"],
4-
"contributors": []
3+
"authors": [
4+
"sanderploegsma"
5+
],
6+
"contributors": [
7+
"kahgoh"
8+
]
59
}

concepts/datetime/about.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,18 @@ printer.format(date);
118118
// => "December 3, 2007"
119119
```
120120

121+
A [locale][locale] can also be specified when creating the custom format to format and parse for different regions:
122+
123+
```java
124+
DateTimeFormatter.ofPattern("MMMM d, yyyy", Locale.FRENCH).format(date);
125+
// => décembre 3, 2007
126+
127+
DateTimeFormatter.ofPattern("MMMM d, yyyy", Locale.of("pt")).format(date);
128+
// => dezembro 3, 2007
129+
```
130+
121131
[iso-8601]: https://en.wikipedia.org/wiki/ISO_8601
122132
[localdate-docs]: https://docs.oracle.com/javase/8/docs/api/java/time/LocalDate.html
123133
[localdatetime-docs]: https://docs.oracle.com/javase/8/docs/api/java/time/LocalDateTime.html
134+
[locale]: https://docs.oracle.com/javase/8/docs/api/java/util/Locale.html
124135
[datetimeformatter-docs]: https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html

concepts/datetime/introduction.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,14 @@ printer.format(date);
8686
// => "December 3, 2007"
8787
```
8888

89+
A locale can also be specified when creating the custom format to format and parse for different regions:
90+
91+
```java
92+
DateTimeFormatter.ofPattern("MMMM d, yyyy", Locale.FRENCH).format(date);
93+
// => décembre 3, 2007
94+
95+
DateTimeFormatter.ofPattern("MMMM d, yyyy", Locale.of("pt")).format(date);
96+
// => dezembro 3, 2007
97+
```
98+
8999
[iso-8601]: https://en.wikipedia.org/wiki/ISO_8601

exercises/concept/booking-up-for-beauty/.docs/introduction.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,14 @@ printer.format(date);
8888
// => "December 3, 2007"
8989
```
9090

91+
A locale can also be specified when creating the custom format to format and parse for different regions:
92+
93+
```java
94+
DateTimeFormatter.ofPattern("MMMM d, yyyy", Locale.FRENCH).format(date);
95+
// => décembre 3, 2007
96+
97+
DateTimeFormatter.ofPattern("MMMM d, yyyy", Locale.of("pt")).format(date);
98+
// => dezembro 3, 2007
99+
```
100+
91101
[iso-8601]: https://en.wikipedia.org/wiki/ISO_8601

0 commit comments

Comments
 (0)