本文整理匯總了Java中org.joda.time.MutableDateTime.setDayOfWeek方法的典型用法代碼示例。如果您正苦於以下問題:Java MutableDateTime.setDayOfWeek方法的具體用法?Java MutableDateTime.setDayOfWeek怎麽用?Java MutableDateTime.setDayOfWeek使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.joda.time.MutableDateTime
的用法示例。
在下文中一共展示了MutableDateTime.setDayOfWeek方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setDateTime
import org.joda.time.MutableDateTime; //導入方法依賴的package包/類
/**
* Sets the correct part of a {@link DateTime} corresponding to a
* {@link SqlDatePartFunction}.
*
* @param value The value to be set for the dateTime with the sqlDatePartFn
* @param sqlDatePartFn The function used to extract part of a date with sql.
* @param dateTime The original dateTime to create a copy of.
*/
protected void setDateTime(int value, SqlDatePartFunction sqlDatePartFn, MutableDateTime dateTime) {
if (YEAR.equals(sqlDatePartFn)) {
dateTime.setYear(value);
} else if (MONTH.equals(sqlDatePartFn)) {
dateTime.setMonthOfYear(value);
} else if (WEEK.equals(sqlDatePartFn)) {
dateTime.setWeekOfWeekyear(value);
dateTime.setDayOfWeek(1);
} else if (DAYOFYEAR.equals(sqlDatePartFn)) {
dateTime.setDayOfYear(value);
} else if (HOUR.equals(sqlDatePartFn)) {
dateTime.setHourOfDay(value);
} else if (MINUTE.equals(sqlDatePartFn)) {
dateTime.setMinuteOfHour(value);
} else if (SECOND.equals(sqlDatePartFn)) {
dateTime.setSecondOfMinute(value);
} else {
throw new IllegalArgumentException("Can't set value " + value + " for " + sqlDatePartFn);
}
}
示例2: getCurrentWeekTimeRecords
import org.joda.time.MutableDateTime; //導入方法依賴的package包/類
@Override
public List<TimedEventRecord> getCurrentWeekTimeRecords(CallingContext context, int weekOffsetfromNow) {
// Based on today, get current events
MutableDateTime now = new MutableDateTime();
now.setDayOfWeek(1);
return RangedEventGenerator.generateWeeklyEvents(now.toDateTime());
}