java.util.Calendar.setMinimalDaysInFirstWeek()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(162)

本文整理了Java中java.util.Calendar.setMinimalDaysInFirstWeek()方法的一些代码示例,展示了Calendar.setMinimalDaysInFirstWeek()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Calendar.setMinimalDaysInFirstWeek()方法的具体详情如下:
包路径:java.util.Calendar
类名称:Calendar
方法名:setMinimalDaysInFirstWeek

Calendar.setMinimalDaysInFirstWeek介绍

[英]Sets the minimal days in the first week of the year.
[中]

代码示例

代码示例来源:origin: apache/hive

@Override
 public void initCalendar() {
  /* code copied over from UDFWeekOfYear implementation */
  calendar.setFirstDayOfWeek(Calendar.MONDAY);
  calendar.setMinimalDaysInFirstWeek(4);
 }
}

代码示例来源:origin: apache/hive

@Override
 public void initCalendar() {
  /* code copied over from UDFWeekOfYear implementation */
  calendar.setFirstDayOfWeek(Calendar.MONDAY);
  calendar.setMinimalDaysInFirstWeek(4);
 }
}

代码示例来源:origin: apache/hive

@Override
public void initCalendar() {
 // code copied over from UDFWeekOfYear implementation
 calendar.setFirstDayOfWeek(Calendar.MONDAY);
 calendar.setMinimalDaysInFirstWeek(4);
}

代码示例来源:origin: apache/hive

public UDFWeekOfYear() {
 calendar.setFirstDayOfWeek(Calendar.MONDAY);
 calendar.setMinimalDaysInFirstWeek(4);
}

代码示例来源:origin: apache/drill

private void initCalendar() {
  /* code copied over from UDFWeekOfYear implementation */
  calendar.setFirstDayOfWeek(Calendar.MONDAY);
  calendar.setMinimalDaysInFirstWeek(4);
 }
}

代码示例来源:origin: apache/drill

public UDFWeekOfYear() {
 calendar.setFirstDayOfWeek(Calendar.MONDAY);
 calendar.setMinimalDaysInFirstWeek(4);
}

代码示例来源:origin: apache/drill

private void initCalendar() {

  // code copied over from UDFWeekOfYear implementation
  calendar.setFirstDayOfWeek(Calendar.MONDAY);
  calendar.setMinimalDaysInFirstWeek(4);
 }
}

代码示例来源:origin: apache/drill

private void initCalendar() {
  /* code copied over from UDFWeekOfYear implementation */
  calendar.setFirstDayOfWeek(Calendar.MONDAY);
  calendar.setMinimalDaysInFirstWeek(4);
 }
}

代码示例来源:origin: pentaho/pentaho-kettle

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 ) );
}

代码示例来源:origin: robovm/robovm

/**
 * 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());
}

代码示例来源:origin: lealone/Lealone

/**
 * 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);
}

代码示例来源:origin: pentaho/pentaho-kettle

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 );
}

代码示例来源:origin: lealone/Lealone

/**
 * 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;
}

代码示例来源:origin: org.apache.commons/commons-lang3

@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());
}

代码示例来源:origin: org.apache.commons/commons-lang3

@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));
  }
}

代码示例来源:origin: pentaho/mondrian

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;
    }
  }
}

代码示例来源:origin: com.liferay.portal/com.liferay.portal.kernel

/**
 * 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);
}

代码示例来源:origin: com.liferay.portal/com.liferay.portal.kernel

myCurrent.clear(Calendar.DST_OFFSET);
myCurrent.setTimeZone(TimeZoneUtil.getTimeZone(StringPool.UTC));
myCurrent.setMinimalDaysInFirstWeek(4);
myCurrent.setFirstDayOfWeek(dtStart.getFirstDayOfWeek());
myCurrent.set(Calendar.SECOND, 0);

代码示例来源:origin: com.liferay.portal/com.liferay.portal.kernel

candidate.clear(Calendar.DST_OFFSET);
candidate.setTimeZone(TimeZoneUtil.getTimeZone(StringPool.UTC));
candidate.setMinimalDaysInFirstWeek(4);
candidate.setFirstDayOfWeek(dtStart.getFirstDayOfWeek());

代码示例来源:origin: stackoverflow.com

public static Calendar getISOCalendar() {
  Calendar calendar = Calendar.getInstance();
  calendar.setMinimalDaysInFirstWeek(4);
  calendar.setFirstDayOfWeek(Calendar.MONDAY);
  return calendar;
}

相关文章