This exercise comes from the Horstmann Core Java book for the impatient:
Write a program that demonstrates date and time formatting styles in [...] Thailand (with Thai numbers).
I tried to solve the exercises with the following snippet:
Locale locale = Locale.forLanguageTag("th-TH-TH"); LocalDateTime dateTime = LocalDateTime.now(); DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM); System.out.println(formatter.withLocale(locale).format(dateTime));
The problem is that although the month name is given correctly in Thai (at least I think so, because I donβt know Thai), the numbers are still formatted with Arabic numbers, the output is as follows:
3 ΰΈ.ΰΈ’. 2017, 22:42:16
I tried different language tags ( "th-TH" , "th-TH-TH" , "th-TH-u-nu-thai" ) to no avail. What should I change for the program to work as I want? I am using JDK 1.8.0_131 for Windows 10 64 bit.
lukeg source share