本文整理了Java中java.util.Calendar.setFirstDayOfWeek()
方法的一些代码示例,展示了Calendar.setFirstDayOfWeek()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Calendar.setFirstDayOfWeek()
方法的具体详情如下:
包路径:java.util.Calendar
类名称:Calendar
方法名:setFirstDayOfWeek
[英]Sets the first day of the week for this Calendar. The value should be a day of the week such as MONDAY.
[中]设置此日历一周的第一天。该值应为一周中的某一天,如星期一。
代码示例来源:origin: org.apache.poi/poi
public int getWeekNo(Calendar cal, int weekStartOn) {
if (weekStartOn == 1) {
cal.setFirstDayOfWeek(Calendar.SUNDAY);
} else {
cal.setFirstDayOfWeek(Calendar.MONDAY);
}
return cal.get(Calendar.WEEK_OF_YEAR);
}
代码示例来源:origin: springside/springside4
private static int getWithMondayFirst(final Date date, int field) {
Validate.notNull(date, "The date must not be null");
Calendar cal = Calendar.getInstance();
cal.setFirstDayOfWeek(Calendar.MONDAY);
cal.setTime(date);
return cal.get(field);
}
代码示例来源:origin: vipshop/vjtools
private static int getWithMondayFirst(final Date date, int field) {
Validate.notNull(date, "The date must not be null");
Calendar cal = Calendar.getInstance();
cal.setFirstDayOfWeek(Calendar.MONDAY);
cal.setTime(date);
return cal.get(field);
}
代码示例来源: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: looly/hutool
/**
* 转换为Calendar
*
* @param zone 时区 {@link TimeZone}
* @param locale 地域 {@link Locale}
* @return {@link Calendar}
*/
public Calendar toCalendar(TimeZone zone, Locale locale) {
if (null == locale) {
locale = Locale.getDefault(Locale.Category.FORMAT);
}
final Calendar cal = (null != zone) ? Calendar.getInstance(zone, locale) : Calendar.getInstance(locale);
cal.setFirstDayOfWeek(firstDayOfWeek.getValue());
cal.setTime(this);
return cal;
}
代码示例来源: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: looly/hutool
/**
* 转换为Calendar
*
* @param zone 时区 {@link TimeZone}
* @param locale 地域 {@link Locale}
* @return {@link Calendar}
*/
public Calendar toCalendar(TimeZone zone, Locale locale) {
if (null == locale) {
locale = Locale.getDefault(Locale.Category.FORMAT);
}
final Calendar cal = (null != zone) ? Calendar.getInstance(zone, locale) : Calendar.getInstance(locale);
cal.setFirstDayOfWeek(firstDayOfWeek.getValue());
cal.setTime(this);
return cal;
}
代码示例来源: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: looly/hutool
/**
* 获取某周的结束时间
*
* @param calendar 日期 {@link Calendar}
* @param isSundayAsLastDay 是否周日做为一周的最后一天(false表示周六做为最后一天)
* @return {@link Calendar}
* @since 3.1.2
*/
public static Calendar endOfWeek(Calendar calendar, boolean isSundayAsLastDay) {
if (isSundayAsLastDay) {
// 设置周一为一周开始
calendar.setFirstDayOfWeek(Week.MONDAY.getValue());
calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
} else {
calendar.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
}
return endOfDay(calendar);
}
代码示例来源:origin: looly/hutool
/**
* 获取某周的开始时间,周一定为一周的开始时间
*
* @param calendar 日期 {@link Calendar}
* @param isMondayAsFirstDay 是否周一做为一周的第一天(false表示周日做为第一天)
* @return {@link Calendar}
* @since 3.1.2
*/
public static Calendar beginOfWeek(Calendar calendar, boolean isMondayAsFirstDay) {
if (isMondayAsFirstDay) {
// 设置周一为一周开始
calendar.setFirstDayOfWeek(Week.MONDAY.getValue());
calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
} else {
calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
}
return beginOfDay(calendar);
}
代码示例来源:origin: looly/hutool
/**
* 获取某周的开始时间,周一定为一周的开始时间
*
* @param calendar 日期 {@link Calendar}
* @param isMondayAsFirstDay 是否周一做为一周的第一天(false表示周日做为第一天)
* @return {@link Calendar}
* @since 3.1.2
*/
public static Calendar beginOfWeek(Calendar calendar, boolean isMondayAsFirstDay) {
if (isMondayAsFirstDay) {
// 设置周一为一周开始
calendar.setFirstDayOfWeek(Week.MONDAY.getValue());
calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
} else {
calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
}
return beginOfDay(calendar);
}
代码示例来源:origin: looly/hutool
/**
* 获取某周的结束时间
*
* @param calendar 日期 {@link Calendar}
* @param isSundayAsLastDay 是否周日做为一周的最后一天(false表示周六做为最后一天)
* @return {@link Calendar}
* @since 3.1.2
*/
public static Calendar endOfWeek(Calendar calendar, boolean isSundayAsLastDay) {
if (isSundayAsLastDay) {
// 设置周一为一周开始
calendar.setFirstDayOfWeek(Week.MONDAY.getValue());
calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
} else {
calendar.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
}
return endOfDay(calendar);
}
代码示例来源: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));
}
}
内容来源于网络,如有侵权,请联系作者删除!