@Override public void initCalendar() { /* code copied over from UDFWeekOfYear implementation */ calendar.setFirstDayOfWeek(Calendar.MONDAY); calendar.setMinimalDaysInFirstWeek(4); } }
@Override public void initCalendar() { /* code copied over from UDFWeekOfYear implementation */ calendar.setFirstDayOfWeek(Calendar.MONDAY); calendar.setMinimalDaysInFirstWeek(4); } }
@Override public void initCalendar() { // code copied over from UDFWeekOfYear implementation calendar.setFirstDayOfWeek(Calendar.MONDAY); calendar.setMinimalDaysInFirstWeek(4); }
public UDFWeekOfYear() { calendar.setFirstDayOfWeek(Calendar.MONDAY); calendar.setMinimalDaysInFirstWeek(4); }
private void initCalendar() { /* code copied over from UDFWeekOfYear implementation */ calendar.setFirstDayOfWeek(Calendar.MONDAY); calendar.setMinimalDaysInFirstWeek(4); } }
public UDFWeekOfYear() { calendar.setFirstDayOfWeek(Calendar.MONDAY); calendar.setMinimalDaysInFirstWeek(4); }
private void initCalendar() { // code copied over from UDFWeekOfYear implementation calendar.setFirstDayOfWeek(Calendar.MONDAY); calendar.setMinimalDaysInFirstWeek(4); } }
private void initCalendar() { /* code copied over from UDFWeekOfYear implementation */ calendar.setFirstDayOfWeek(Calendar.MONDAY); calendar.setMinimalDaysInFirstWeek(4); } }
public static Object weekOfYearISO8601( ValueMetaInterface metaA, Object dataA ) throws KettleValueException { if ( dataA == null ) { return null; } 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 ) ); }
/** * Constructs a {@code Calendar} instance using the given {@code TimeZone} and {@code Locale}. */ protected Calendar(TimeZone timezone, Locale locale) { this(timezone); LocaleData localeData = LocaleData.get(locale); setFirstDayOfWeek(localeData.firstDayOfWeek.intValue()); setMinimalDaysInFirstWeek(localeData.minimalDaysInFirstWeek.intValue()); }
/** * Returns the week of the year according to the ISO 8601 specification. The * spec defines the first week of the year as the week which contains at * least 4 days of the new year. The week starts at Monday. Therefore * December 29th - 31th could belong to the next year and January 1st - 3th * could belong to the previous year. If January 1st is on Thursday (or * earlier) it belongs to the first week, otherwise to the last week of the * previous year. Hence January 4th always belongs to the first week while * the December 28th always belongs to the last week. * * @author Robert Rathsack * @param date the date object which week of year should be calculated * @return the week of the year */ public static int getIsoWeek(java.util.Date date) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(date.getTime()); c.setFirstDayOfWeek(Calendar.MONDAY); c.setMinimalDaysInFirstWeek(4); return c.get(Calendar.WEEK_OF_YEAR); }
public static Object yearOfDateISO8601( ValueMetaInterface metaA, Object dataA ) throws KettleValueException { if ( dataA == null ) { return null; } 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 ); }
/** * Returns the year according to the ISO week definition. * * @author Robert Rathsack * * @param date the date object which year should be calculated * @return the year */ public static int getIsoYear(java.util.Date date) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(date.getTime()); cal.setFirstDayOfWeek(Calendar.MONDAY); cal.setMinimalDaysInFirstWeek(4); int year = getYear(cal); int month = cal.get(Calendar.MONTH); int week = cal.get(Calendar.WEEK_OF_YEAR); if (month == 0 && week > 51) { year--; } else if (month == 11 && week == 1) { year++; } return year; }
@Test public void testParser() throws ParseException { final DateParser parser = new FastDateParser("YYYY-'W'ww-u", TimeZone.getDefault(), Locale.getDefault()); final Calendar cal = Calendar.getInstance(); cal.setMinimalDaysInFirstWeek(4); cal.setFirstDayOfWeek(Calendar.MONDAY); cal.clear(); parser.parse(isoForm, new ParsePosition(0), cal); assertEquals(vulgar.getTime(), cal.getTime()); }
@Test public void testPrinter() { final FastDatePrinter printer = new FastDatePrinter("YYYY-'W'ww-u", TimeZone.getDefault(), Locale.getDefault()); vulgar.setMinimalDaysInFirstWeek(4); vulgar.setFirstDayOfWeek(Calendar.MONDAY); assertEquals(isoForm, printer.format(vulgar)); } }
void apply(Calendar calendar) { switch (this) { case vbUseSystem: break; case vbFirstJan1: calendar.setMinimalDaysInFirstWeek(1); break; case vbFirstFourDays: calendar.setMinimalDaysInFirstWeek(4); break; case vbFirstFullWeek: calendar.setMinimalDaysInFirstWeek(7); break; } } }
/** * Method setDtStart */ public void setDtStart(Calendar start) { int oldStart = 0; if (dtStart != null) { oldStart = dtStart.getFirstDayOfWeek(); } else { oldStart = Calendar.MONDAY; } if (start == null) { dtStart = CalendarFactoryUtil.getCalendar( TimeZoneUtil.getTimeZone(StringPool.UTC)); dtStart.setTime(new Date(0L)); } else { dtStart = (Calendar)start.clone(); dtStart.clear(Calendar.ZONE_OFFSET); dtStart.clear(Calendar.DST_OFFSET); dtStart.setTimeZone(TimeZoneUtil.getTimeZone(StringPool.UTC)); } dtStart.setMinimalDaysInFirstWeek(4); dtStart.setFirstDayOfWeek(oldStart); dtStart.set(Calendar.SECOND, 0); dtStart.set(Calendar.MILLISECOND, 0); }
myCurrent.clear(Calendar.DST_OFFSET); myCurrent.setTimeZone(TimeZoneUtil.getTimeZone(StringPool.UTC)); myCurrent.setMinimalDaysInFirstWeek(4); myCurrent.setFirstDayOfWeek(dtStart.getFirstDayOfWeek()); myCurrent.set(Calendar.SECOND, 0);
candidate.clear(Calendar.DST_OFFSET); candidate.setTimeZone(TimeZoneUtil.getTimeZone(StringPool.UTC)); candidate.setMinimalDaysInFirstWeek(4); candidate.setFirstDayOfWeek(dtStart.getFirstDayOfWeek());
public static Calendar getISOCalendar() { Calendar calendar = Calendar.getInstance(); calendar.setMinimalDaysInFirstWeek(4); calendar.setFirstDayOfWeek(Calendar.MONDAY); return calendar; }