本文整理匯總了Java中org.joda.time.MutableDateTime.set方法的典型用法代碼示例。如果您正苦於以下問題:Java MutableDateTime.set方法的具體用法?Java MutableDateTime.set怎麽用?Java MutableDateTime.set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.joda.time.MutableDateTime
的用法示例。
在下文中一共展示了MutableDateTime.set方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: computeDateTime
import org.joda.time.MutableDateTime; //導入方法依賴的package包/類
public Date computeDateTime() {
Date dateFieldInput = getDate();
if (dateFieldInput == null) {
return null;
}
Integer hoursInput = getHours();
Integer minutesInput = getMinutes();
AM_PM amOrPmInput = getAmOrPm();
// Get year, month and day ignoring any timezone of the Date object
Calendar cal = Calendar.getInstance();
cal.setTime(dateFieldInput);
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH) + 1;
int day = cal.get(Calendar.DAY_OF_MONTH);
int hours = (hoursInput == null ? 0 : hoursInput % 24);
int minutes = (minutesInput == null ? 0 : minutesInput);
// Use the input to create a date object with proper timezone
MutableDateTime date = new MutableDateTime(year, month, day, hours, minutes, 0, 0,
DateTimeZone.forTimeZone(getClientTimeZone()));
// Adjust for halfday if needed
if (use12HourFormat()) {
int halfday = (amOrPmInput == AM_PM.PM ? 1 : 0);
date.set(DateTimeFieldType.halfdayOfDay(), halfday);
date.set(DateTimeFieldType.hourOfHalfday(), hours % 12);
}
// The date will be in the server's timezone
return newDateInstance(date.getMillis());
}
示例2: set
import org.joda.time.MutableDateTime; //導入方法依賴的package包/類
public FDate set(final FDateField field, final int value) {
final MutableDateTime delegate = newMutableDateTime();
delegate.set(field.jodaTimeValue(), value);
return new FDate(delegate);
}