[
https://issues.apache.org/jira/browse/FREEMARKER-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16454633#comment-16454633
]
James Barnes commented on FREEMARKER-95:
----------------------------------------
Thank you for such a quick response! So I think the issue is that when I set
the locale to Thai in FreeMarker with code that looks like this:
{code:java}
room=<#setting locale="th_TH"><#setting
date_format="yyyy-MM-dd">คุณมีการจองใหม่สำหรับวันที่
${payload.bookingDate?date?string.full}{code}
FreeMarker uses the Buddhist calendar to look up the day of the week, without
first converting the year. So if the day in question were today (Thursday April
26 2018), FreeMarker returns Wednesday April 26 2018 in Thai, but is actually
referring to Wednesday April 26 1475. Initially, I also thought it might have
been an issue with Java 8 as well, but if I run this simple Java:
{code:java}
String date_s = " 2018-04-26";
SimpleDateFormat dt = new SimpleDateFormat("yyyy-MM-dd");
Locale th_TH = new Locale("th", "TH");
try {
Date date = dt.parse(date_s);
SimpleDateFormat dt1 = new SimpleDateFormat("EEEE MM-dd-yyyy",
th_TH);
SimpleDateFormat dt2 = new SimpleDateFormat("EEEE MM-dd-yyyy");
System.out.println(dt1.format(date));
System.out.println(dt2.format(date));
} catch(Exception e){
System.out.println(e.toString());
}
{code}
I get the correct day of the week and year: วันพฤหัสบดี 04-26-2561 (Thursday
04-26-2018). We are actually only interested in the date itself, so no
timezones are being passed, just "MM-dd-yyyy". Let me know if you have any
clarification questions on our use case.
> Wrong day of the week shown for the Thai locale
> -----------------------------------------------
>
> Key: FREEMARKER-95
> URL: https://issues.apache.org/jira/browse/FREEMARKER-95
> Project: Apache Freemarker
> Issue Type: Bug
> Reporter: James Barnes
> Priority: Major
>
> Freemarker returns the wrong day of the week when the user sets the the
> locale to Thai. It would seem that this is a result of Freemarker not
> correcting for the Buddhist calendar. The day of the week is currently out of
> sync but will be back in sync on Feb 28 2019 and then will be out of sync
> again on Feb 29 2020. So currently when the user sets the locale to Thai,
> FreeMarker uses the days of the week from 1475 on the Gregorian calendar.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)