diff --git a/concepts/datetime/.meta/config.json b/concepts/datetime/.meta/config.json index f68620354..e6bd977c0 100644 --- a/concepts/datetime/.meta/config.json +++ b/concepts/datetime/.meta/config.json @@ -1,5 +1,9 @@ { "blurb": "There are several classes in Java to work with dates and time.", - "authors": ["sanderploegsma"], - "contributors": [] + "authors": [ + "sanderploegsma" + ], + "contributors": [ + "kahgoh" + ] } diff --git a/concepts/datetime/about.md b/concepts/datetime/about.md index 8ab1fbad6..ebeb1b3a3 100644 --- a/concepts/datetime/about.md +++ b/concepts/datetime/about.md @@ -118,7 +118,18 @@ printer.format(date); // => "December 3, 2007" ``` +A [locale][locale] can also be specified when creating the custom format to format and parse for different regions: + +```java +DateTimeFormatter.ofPattern("MMMM d, yyyy", Locale.FRENCH).format(date); +// => décembre 3, 2007 + +DateTimeFormatter.ofPattern("MMMM d, yyyy", Locale.of("pt")).format(date); +// => dezembro 3, 2007 +``` + [iso-8601]: https://en.wikipedia.org/wiki/ISO_8601 [localdate-docs]: https://docs.oracle.com/javase/8/docs/api/java/time/LocalDate.html [localdatetime-docs]: https://docs.oracle.com/javase/8/docs/api/java/time/LocalDateTime.html +[locale]: https://docs.oracle.com/javase/8/docs/api/java/util/Locale.html [datetimeformatter-docs]: https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html diff --git a/concepts/datetime/introduction.md b/concepts/datetime/introduction.md index 2b9513189..d4fbd5960 100644 --- a/concepts/datetime/introduction.md +++ b/concepts/datetime/introduction.md @@ -86,4 +86,14 @@ printer.format(date); // => "December 3, 2007" ``` +A locale can also be specified when creating the custom format to format and parse for different regions: + +```java +DateTimeFormatter.ofPattern("MMMM d, yyyy", Locale.FRENCH).format(date); +// => décembre 3, 2007 + +DateTimeFormatter.ofPattern("MMMM d, yyyy", Locale.of("pt")).format(date); +// => dezembro 3, 2007 +``` + [iso-8601]: https://en.wikipedia.org/wiki/ISO_8601 diff --git a/exercises/concept/booking-up-for-beauty/.docs/introduction.md b/exercises/concept/booking-up-for-beauty/.docs/introduction.md index ed132331c..57768dafe 100644 --- a/exercises/concept/booking-up-for-beauty/.docs/introduction.md +++ b/exercises/concept/booking-up-for-beauty/.docs/introduction.md @@ -88,4 +88,14 @@ printer.format(date); // => "December 3, 2007" ``` +A locale can also be specified when creating the custom format to format and parse for different regions: + +```java +DateTimeFormatter.ofPattern("MMMM d, yyyy", Locale.FRENCH).format(date); +// => décembre 3, 2007 + +DateTimeFormatter.ofPattern("MMMM d, yyyy", Locale.of("pt")).format(date); +// => dezembro 3, 2007 +``` + [iso-8601]: https://en.wikipedia.org/wiki/ISO_8601