本文整理了Java中org.joda.time.LocalDateTime.withTime()
方法的一些代码示例,展示了LocalDateTime.withTime()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalDateTime.withTime()
方法的具体详情如下:
包路径:org.joda.time.LocalDateTime
类名称:LocalDateTime
方法名:withTime
[英]Returns a copy of this datetime with the specified time, retaining the date fields.
If the time is already the time passed in, then this
is returned.
To set a single field use the properties, for example:
LocalDateTime set = dt.hourOfDay().setCopy(6);
[中]返回具有指定时间的此datetime的副本,保留日期字段。
如果时间已经是传入的时间,则返回this
。
要设置单个字段,请使用属性,例如:
LocalDateTime set = dt.hourOfDay().setCopy(6);
代码示例来源:origin: effektif/effektif
private Object endOfDay(LocalDateTime time) {
return time.withTime(23, 59, 59, 999);
}
}
代码示例来源:origin: com.synaptix/SynaptixWidget
@Override
public void propertyChange(final PropertyChangeEvent evt) {
if ("calendar".equals(evt.getPropertyName())) {
final LocalDateTime dateTime = (LocalDateTime) this.formattedTextField.getValue();
if (this.isMax) {
this.formattedTextField.setValue(dateTime.withTime(23, 59, 59, 999));
} else {
this.formattedTextField.setValue(dateTime.withTime(0, 0, 0, 0));
}
}
}
}
代码示例来源:origin: com.synaptix/SynaptixWidget
@Override
public void propertyChange(final PropertyChangeEvent evt) {
if ("calendar".equals(evt.getPropertyName())) {
final LocalDateTime dateTime = (LocalDateTime) this.formattedTextField.getValue();
if (this.isMax) {
this.formattedTextField.setValue(dateTime.withTime(23, 59, 59, 999));
} else {
this.formattedTextField.setValue(dateTime.withTime(0, 0, 0, 0));
}
} else if ("value".equals(evt.getPropertyName())) {
fireValuesChanged();
}
}
}
代码示例来源:origin: com.effektif/effektif-workflow-api
@Override
public LocalDateTime resolve(LocalDateTime base) {
LocalDateTime time = null;
if (HOUR_OF_DAY.equals(indexUnit)) {
time = base.withTime(index, 0, 0, 0);
if (!time.isAfter(base)) {
return time.plusDays(1);
}
} else if (DAY_OF_WEEK.equals(indexUnit)) {
time = base
.withDayOfWeek(index)
.withTime(0, 0, 0, 0);
if (!time.isAfter(base)) {
time = time.plusWeeks(1);
}
} else if (DAY_OF_MONTH.equals(indexUnit)) {
time = base
.withDayOfMonth(index)
.withTime(0, 0, 0, 0);
if (!time.isAfter(base)) {
time = time.plusMonths(1);
}
}
if (atHour!=null) {
time = time.withTime(atHour, atMinute!=null ? atMinute : 0, 0, 0);
}
return time;
}
代码示例来源:origin: effektif/effektif
@Override
public LocalDateTime resolve(LocalDateTime base) {
LocalDateTime time = null;
if (HOUR_OF_DAY.equals(indexUnit)) {
time = base.withTime(index, 0, 0, 0);
if (!time.isAfter(base)) {
return time.plusDays(1);
}
} else if (DAY_OF_WEEK.equals(indexUnit)) {
time = base
.withDayOfWeek(index)
.withTime(0, 0, 0, 0);
if (!time.isAfter(base)) {
time = time.plusWeeks(1);
}
} else if (DAY_OF_MONTH.equals(indexUnit)) {
time = base
.withDayOfMonth(index)
.withTime(0, 0, 0, 0);
if (!time.isAfter(base)) {
time = time.plusMonths(1);
}
}
if (atHour!=null) {
time = time.withTime(atHour, atMinute!=null ? atMinute : 0, 0, 0);
}
return time;
}
代码示例来源:origin: com.synaptix/SynaptixWidget
@Override
public void actionPerformed(ActionEvent e) {
popupMenu.setVisible(false);
Date date = monthView.getSelectionDate();
if (date != null) {
LocalDateTime oldValue = (LocalDateTime) formattedTextField.getValue();
if (oldValue == null) {
oldValue = new LocalDateTime();
}
Calendar c = Calendar.getInstance();
c.setTime(date);
LocalDateTime newValue = oldValue.withDate(c.get(Calendar.YEAR), c.get(Calendar.MONTH) + 1, c.get(Calendar.DAY_OF_MONTH));
newValue = newValue.withTime(0, 0, 0, 0);
formattedTextField.setValue(newValue);
formattedTextField.firePropertyChange("calendar", false, true);
} else {
formattedTextField.setValue(null);
}
}
});
代码示例来源:origin: effektif/effektif
LocalDateTime atTime = time.withTime(atHour, atMinute!=null ? atMinute : 0, 0, 0);
if (atTime.isBefore(time)) {
time = atTime.plusDays(1);
time = time.withTime(23, 59, 59, 999);
代码示例来源:origin: com.effektif/effektif-workflow-api
LocalDateTime atTime = time.withTime(atHour, atMinute!=null ? atMinute : 0, 0, 0);
if (atTime.isBefore(time)) {
time = atTime.plusDays(1);
time = time.withTime(23, 59, 59, 999);
代码示例来源:origin: effektif/effektif
@Test
public void testNextThursday() {
LocalDateTime base = new LocalDateTime(2015, 12, 28, 9, 0, 0, 0);
LocalDateTime absoluteTime = NextRelativeTime
.dayOfWeek(DateTimeConstants.THURSDAY)
.resolve(base);
assertEquals(base
.withDayOfWeek(DateTimeConstants.THURSDAY)
.withTime(0, 0, 0, 0), absoluteTime);
}
代码示例来源:origin: effektif/effektif
@Test
public void testTomorrowAt11() {
LocalDateTime base = new LocalDateTime(2015, 12, 28, 9, 0, 0, 0);
LocalDateTime absoluteTime = RelativeTime.days(1).at(11,00).resolve(base);
assertEquals(base
.plusDays(1)
.withTime(11, 0, 0, 0), absoluteTime);
}
代码示例来源:origin: effektif/effektif
@Test
public void testNextThursdayAt15() {
LocalDateTime base = new LocalDateTime(2015, 12, 28, 9, 0, 0, 0);
LocalDateTime absoluteTime = NextRelativeTime
.dayOfWeek(DateTimeConstants.THURSDAY)
.at(15,30)
.resolve(base);
assertEquals(base
.withDayOfWeek(DateTimeConstants.THURSDAY)
.withTime(15, 30, 0, 0), absoluteTime);
}
代码示例来源:origin: effektif/effektif
assertEquals("date", ((DateType) workflow.getVariables().get(10).getType()).getKind());
LocalDateTime defaultValue11 = (LocalDateTime) workflow.getVariables().get(10).getDefaultValue();
assertEquals(now.withTime(0, 0, 0, 0), defaultValue11.withTime(0, 0, 0, 0));
内容来源于网络,如有侵权,请联系作者删除!