I'm trying to use the Calculator's "Week of year of date A" function to figure out the number of the week for a particular date (i.e. - January 1 is week 1 and Dec 31 is usually week 52). The problem is that my kettle server is running in some strange java Locale and it returns week 1 for December 30 2015. This is a documented problem on stackoverflow when the Locale is set incorrectly in java. I do not have the ability to control the Locale on my server. Is there any way to set the Locale through the kettle job?
I glanced at the source code for ValueDataUtil which is used by the calculator and here is the problematic method:
Source: https://github.com/cwarden/kettle/bl...eDataUtil.java (see lines 978-990)
The Calendar.getInstance uses the default Locale unless it is passed in to the constructor like Calendar.getInstance(requestedLocale). Although I did not see any way to pass the Locale to the Calendar.getInstance method :(
I glanced at the source code for ValueDataUtil which is used by the calculator and here is the problematic method:
Code:
public static Object weekOfYear(ValueMetaInterface metaA, Object dataA) throws KettleValueException {
if (dataA==null) return null;
if (metaA.isDate())
{
Calendar calendar = Calendar.getInstance();
calendar.setTime( metaA.getDate(dataA) );
return new Long( calendar.get(Calendar.WEEK_OF_YEAR) );
}
throw new KettleValueException("The 'weekOfYear' function only works with dates");
}
The Calendar.getInstance uses the default Locale unless it is passed in to the constructor like Calendar.getInstance(requestedLocale). Although I did not see any way to pass the Locale to the Calendar.getInstance method :(