本文整理了Java中org.joda.time.DateTime.withField()
方法的一些代码示例,展示了DateTime.withField()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DateTime.withField()
方法的具体详情如下:
包路径:org.joda.time.DateTime
类名称:DateTime
方法名:withField
[英]Returns a copy of this datetime with the specified field set to a new value.
For example, if the field type is hourOfDay
then the hour of day field would be changed in the returned instance. If the field type is null, then this
is returned.
These three lines are equivalent:
DateTime updated = dt.withField(DateTimeFieldType.dayOfMonth(), 6);
DateTime updated = dt.dayOfMonth().setCopy(6);
DateTime updated = dt.property(DateTimeFieldType.dayOfMonth()).setCopy(6);
[中]返回此datetime的副本,并将指定字段设置为新值。
例如,如果字段类型为hourOfDay
,则返回实例中的小时字段将发生更改。如果字段类型为空,则返回this
。
这三条线是等效的:
DateTime updated = dt.withField(DateTimeFieldType.dayOfMonth(), 6);
DateTime updated = dt.dayOfMonth().setCopy(6);
DateTime updated = dt.property(DateTimeFieldType.dayOfMonth()).setCopy(6);
代码示例来源:origin: perfectsense/dari
protected DateTime every(DateTime currentTime, DateTimeFieldType unit, int offset, int interval) {
DateTime d = currentTime.property(unit).roundFloorCopy();
d = d.withFieldAdded(unit.getDurationType(), offset);
return d.withField(unit, (d.get(unit) / interval) * interval);
}
代码示例来源:origin: FenixEdu/fenixedu-academic
public Interval getWeeklyWorkLoadInterval() {
final DateTime beginningOfSemester = new DateTime(getBegginingOfLessonPeriod());
final DateTime firstMonday = beginningOfSemester.withField(DateTimeFieldType.dayOfWeek(), 1);
final DateTime endOfSemester = new DateTime(getEndOfExamsPeriod());
final DateTime nextLastMonday = endOfSemester.withField(DateTimeFieldType.dayOfWeek(), 1).plusWeeks(1);
return new Interval(firstMonday, nextLastMonday);
}
代码示例来源:origin: FenixEdu/fenixedu-academic
public Interval getInterval() {
final DateTime beginningOfSemester = new DateTime(getAttends().getBegginingOfLessonPeriod());
final DateTime firstMonday = beginningOfSemester.withField(DateTimeFieldType.dayOfWeek(), 1);
final DateTime start = firstMonday.withFieldAdded(DurationFieldType.weeks(), getWeekOffset().intValue());
final DateTime end = start.plusWeeks(1);
return new Interval(start, end);
}
代码示例来源:origin: FenixEdu/fenixedu-academic
public Interval getInterval() {
final ExecutionSemester executionSemester = getExecutionPeriod();
final DateTime beginningOfSemester = new DateTime(executionSemester.getBeginDateYearMonthDay());
final DateTime firstMonday = beginningOfSemester.withField(DateTimeFieldType.dayOfWeek(), 1);
final DateTime endOfSemester = new DateTime(executionSemester.getEndDateYearMonthDay());
final DateTime nextLastMonday = endOfSemester.withField(DateTimeFieldType.dayOfWeek(), 1).plusWeeks(1);
return new Interval(firstMonday, nextLastMonday);
}
代码示例来源:origin: FenixEdu/fenixedu-academic
private static InfoSiteRoomTimeTable run(Space room, Calendar someDay, String executionPeriodID) throws Exception {
final Calendar day = new DateTime(someDay.getTimeInMillis()).withField(DateTimeFieldType.dayOfWeek(), 1).toCalendar(null);
final ExecutionSemester executionSemester = FenixFramework.getDomainObject(executionPeriodID);
return RoomSiteComponentBuilder.getInfoSiteRoomTimeTable(day, room,
executionSemester != null ? executionSemester : ExecutionSemester.readActualExecutionSemester());
}
代码示例来源:origin: org.opencds.cqf/cql-engine
dt.withDate(1, 1, 1);
switch (partial.size()) {
case 1: return dt.withField(DateTimeFieldType.hourOfDay(), partial.getValue(0))
.withField(DateTimeFieldType.minuteOfHour(), 0)
.withField(DateTimeFieldType.secondOfMinute(), 0)
.withField(DateTimeFieldType.millisOfSecond(), 0);
case 2: return dt.withField(DateTimeFieldType.hourOfDay(), partial.getValue(0))
.withField(DateTimeFieldType.minuteOfHour(), partial.getValue(1))
.withField(DateTimeFieldType.secondOfMinute(), 0)
.withField(DateTimeFieldType.millisOfSecond(), 0);
case 3: return dt.withField(DateTimeFieldType.hourOfDay(), partial.getValue(0))
.withField(DateTimeFieldType.minuteOfHour(), partial.getValue(1))
.withField(DateTimeFieldType.secondOfMinute(), partial.getValue(2))
.withField(DateTimeFieldType.millisOfSecond(), 0);
case 4: return dt.withField(DateTimeFieldType.hourOfDay(), partial.getValue(0))
.withField(DateTimeFieldType.minuteOfHour(), partial.getValue(1))
.withField(DateTimeFieldType.secondOfMinute(), partial.getValue(2))
.withField(DateTimeFieldType.millisOfSecond(), partial.getValue(3));
case 1: return dt.withField(DateTimeFieldType.year(), partial.getValue(0))
.withField(DateTimeFieldType.monthOfYear(), 1)
.withField(DateTimeFieldType.dayOfMonth(), 1)
.withField(DateTimeFieldType.hourOfDay(), 0)
.withField(DateTimeFieldType.minuteOfHour(), 0)
.withField(DateTimeFieldType.secondOfMinute(), 0)
.withField(DateTimeFieldType.millisOfSecond(), 0);
case 2: return dt.withField(DateTimeFieldType.year(), partial.getValue(0))
.withField(DateTimeFieldType.monthOfYear(), partial.getValue(1))
.withField(DateTimeFieldType.dayOfMonth(), 1)
内容来源于网络,如有侵权,请联系作者删除!