You are not logged in.
Hello, I'm wondering how to configure locale settings to define Monday as the first day of the week. For example, today is Wednesday, and when I execute:
TalendDate.getPartOfDate("DAY_OF_WEEK", TalendDate.getCurrentDate() );
it returns 4, indicating that the first day of the week is Sunday. I would like it to return 3.
I'm using TOS 5.0.1 with Java, on Win server 2008.
(This also affects week of year in a similar way)
Welcome to Talend Community!
The method getPartDate() gets the return value from java.util.Calendar.
ret = c.get(Calendar.DAY_OF_WEEK);
So you can't change it which is predefined in JDK.
Thanks Pedro. I guess I can workaround the day of week issue with some custom code.
(if day-name = Monday, return 1, if Tues return 2 etc...)
However, the issue with week of year is more challenging. Is there a way to alter the calendar settings in a tMap component? I am a bit of a Java simpleton, but it looks like you may be able to construct a calendar with various locale settings.
For example, if 1-Jan is a Sunday and the first day of the week is Monday, then the week-of-year of 1-Jan should be 52, and week-of-year of 2-Jan should be 1.
Perhaps even more challenging, is I would like to be able to set the first day of the year to be 1-Jul to construct a financial calendar (the Australian FY starts on 1-Jul). In this case, week-of-year #1 begins on the first Monday after 1-Jul, and 2-Aug would be the 33rd day of the year and so on.
After reading java.util.Calendar API, there is a method called setFirstDayOfWeek().
But an interesting thing is that the method can only effect the return values of WEEK_OF_MONTH and WEEK_OF_YEAR. For DAY_OF_WEEK, it does nothing.
Here is my test code.
Calendar c = Calendar.getInstance(); c.setTime(TalendDate.getCurrentDate()); c.setFirstDayOfWeek(Calendar.MONDAY); int rec = c.get(Calendar.WEEK_OF_MONTH); System.out.println(rec);
I think the best way is creating a new custom routine. Just add this line-- c.setFirstDayOfWeek(Calendar.MONDAY);
The API URL:http://docs.oracle.com/javase/6/docs/ap … fWeek(int)