List of usage examples for java.util Calendar setMinimalDaysInFirstWeek
public void setMinimalDaysInFirstWeek(int value)
From source file:org.pentaho.di.core.row.ValueDataUtil.java
public static Object weekOfYearISO8601(ValueMetaInterface metaA, Object dataA) throws KettleValueException { if (dataA == null) { return null; }/*from w w w. j a v a 2s .c o m*/ Calendar calendar = Calendar.getInstance(Locale.ENGLISH); calendar.setMinimalDaysInFirstWeek(4); calendar.setFirstDayOfWeek(Calendar.MONDAY); calendar.setTime(metaA.getDate(dataA)); return new Long(calendar.get(Calendar.WEEK_OF_YEAR)); }
From source file:org.pentaho.di.core.row.ValueDataUtil.java
public static Object yearOfDateISO8601(ValueMetaInterface metaA, Object dataA) throws KettleValueException { if (dataA == null) { return null; }//from ww w.jav a2 s . com Calendar calendar = Calendar.getInstance(Locale.ENGLISH); calendar.setMinimalDaysInFirstWeek(4); calendar.setFirstDayOfWeek(Calendar.MONDAY); calendar.setTime(metaA.getDate(dataA)); int week = calendar.get(Calendar.WEEK_OF_YEAR); int month = calendar.get(Calendar.MONTH); int year = calendar.get(Calendar.YEAR); // fix up for the year taking into account ISO8601 weeks if (week >= 52 && month == 0) { year--; } if (week <= 2 && month == 11) { year++; } return new Long(year); }