本文整理了Java中org.joda.time.DateTime.hourOfDay()
方法的一些代码示例,展示了DateTime.hourOfDay()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DateTime.hourOfDay()
方法的具体详情如下:
包路径:org.joda.time.DateTime
类名称:DateTime
方法名:hourOfDay
[英]Get the hour of day field property which provides access to advanced functionality.
[中]获取“小时”字段属性,该属性提供对高级功能的访问。
代码示例来源:origin: stackoverflow.com
private DateTime roundDate(final DateTime dateTime, final int minutes) {
if (minutes < 1 || 60 % minutes != 0) {
throw new IllegalArgumentException("minutes must be a factor of 60");
}
final DateTime hour = dateTime.hourOfDay().roundFloorCopy();
final long millisSinceHour = new Duration(hour, dateTime).getMillis();
final int roundedMinutes = ((int)Math.round(
millisSinceHour / 60000.0 / minutes)) * minutes;
return hour.plusMinutes(roundedMinutes);
}
代码示例来源:origin: apache/incubator-pinot
case HOURS:
_dateTimeTruncate = (dateTime) -> _outputDateTimeFormatter
.print(dateTime.withHourOfDay((dateTime.getHourOfDay() / sz) * sz).hourOfDay().roundFloorCopy());
break;
case DAYS:
代码示例来源:origin: apache/incubator-druid
@Override
public RexNode convertCall(final SqlRexContext cx, final SqlCall call)
{
final SqlOperator operator = call.getOperator();
if (operator.equals(SqlStdOperatorTable.CURRENT_TIMESTAMP)
|| operator.equals(SqlStdOperatorTable.LOCALTIMESTAMP)) {
return cx.getRexBuilder().makeTimestampLiteral(
Calcites.jodaToCalciteTimestampString(plannerContext.getLocalNow(), plannerContext.getTimeZone()),
RelDataType.PRECISION_NOT_SPECIFIED
);
} else if (operator.equals(SqlStdOperatorTable.CURRENT_TIME) || operator.equals(SqlStdOperatorTable.LOCALTIME)) {
return cx.getRexBuilder().makeTimeLiteral(
Calcites.jodaToCalciteTimeString(plannerContext.getLocalNow(), plannerContext.getTimeZone()),
RelDataType.PRECISION_NOT_SPECIFIED
);
} else if (operator.equals(SqlStdOperatorTable.CURRENT_DATE)) {
return cx.getRexBuilder().makeDateLiteral(
Calcites.jodaToCalciteDateString(
plannerContext.getLocalNow().hourOfDay().roundFloorCopy(),
plannerContext.getTimeZone()
)
);
} else {
throw new ISE("WTF?! Should not have got here, operator was: %s", operator);
}
}
}
代码示例来源:origin: stackoverflow.com
List<DateTime> dtListOld = dt; // your input
List<DateTime> dtListNew = new ArrayList<>();
for (DateTime dateTime : dtListOld) {
dtListNew.add(dateTime.hourOfDay().roundFloorCopy());
}
代码示例来源:origin: stackoverflow.com
Date timestamp = sdf.parse("11/17/2014 06:13:19");
TimeZone timezone = TimeZone.getTimeZone("Europe/Moscow");
DateTimeZone tz = DateTimeZone.forTimeZone(timezone);
DateTime jodaDateTime = new DateTime(timestamp, tz);
System.out.println(jodaDateTime.hourOfDay().get());
代码示例来源:origin: stackoverflow.com
DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyyMMddHHmmss");
DateTime now = DateTime.now();
DateTime other1 = dtf.parseDateTime("20160418184137");
DateTime other2 = dtf.parseDateTime("20160418180000");
DateTime sharpHour = now.hourOfDay().roundFloorCopy();
if (!sharpHour.isEqual(other1.minuteOfDay().roundFloorCopy())) {
System.out.println("Not matching sharp hour: " + other1);
}
DateTime other2Floor = other2.minuteOfDay().roundFloorCopy();
if (sharpHour.isEqual(other2Floor)) {
System.out.println("Matching sharp hour: " + other2);
}
代码示例来源:origin: addthis/hydra
private static String replaceDateElements(DateTime time, String template) {
String result = YY_PATTERN.matcher(template).replaceAll(time.year().getAsString());
result = Y_PATTERN.matcher(result).replaceAll(getTwoDigit(time.year().get()));
result = M_PATTERN.matcher(result).replaceAll(getTwoDigit(time.monthOfYear().get()));
result = D_PATTERN.matcher(result).replaceAll(getTwoDigit(time.dayOfMonth().get()));
result = H_PATTERN.matcher(result).replaceAll(getTwoDigit(time.hourOfDay().get()));
log.debug("template={}, result={}", template, result);
return result;
}
代码示例来源:origin: chengzhx76/weixin-shop-spring-cloud
@Override
public List<BonusPointRecord> getByUserIdAndCurrentMonth(String userId) {
Date currentMonth = DateTime.now().dayOfMonth().withMinimumValue().hourOfDay().withMinimumValue().millisOfDay().withMinimumValue().toDate();
BonusPointRecord bonusPointRecord = new BonusPointRecord();
bonusPointRecord.setAccountId(userId);
bonusPointRecord.setCreateDate(currentMonth);
return bonusPointRecordDao.loadByUSerIdAndCurrentMonth(bonusPointRecord);
}
代码示例来源:origin: org.jasig.portlet/blackboardvc-portlet-api
public SessionForm(ServerConfiguration serverConfiguration) {
this.newSession = true;
this.needToSendInitialEmail = true;
final DateTime startTime = DateTime.now().plusHours(1).hourOfDay().roundFloorCopy();
this.setStartTime(startTime);
this.setEndTime(startTime.plusHours(1));
this.boundaryTime = serverConfiguration.getBoundaryTime();
this.maxCameras = serverConfiguration.getMaxAvailableCameras();
this.maxTalkers = serverConfiguration.getMaxAvailableTalkers();
this.raiseHandOnEnter = serverConfiguration.isRaiseHandOnEnter();
}
代码示例来源:origin: org.opensingular/singular-server-commons
private static String errorCode() {
DateTime now = DateTime.now();
return format("SER-%04d-%02d%02d%02d-%02d%02d-%04d ",
get(now.year()), get(now.monthOfYear()), get(now.dayOfMonth()),
get(now.hourOfDay()), get(now.minuteOfHour()), get(now.secondOfMinute()),
get(now.millisOfSecond()));
}
代码示例来源:origin: org.opencds.cqf/cql-engine
public static Time getTimeOfDay() {
org.joda.time.DateTime dt = org.joda.time.DateTime.now();
int [] values = { dt.hourOfDay().get(), dt.minuteOfHour().get(), dt.secondOfMinute().get(), dt.millisOfSecond().get() };
return new Time(new Partial(fields, values), dt.getZone());
}
代码示例来源:origin: apache/streams
@Test
public void validUTC() {
DateTime parsed = parseUTC("2014-12-25T12:00:00Z");
assertThat(parsed.minuteOfHour().get(), is(equalTo(0)));
assertThat(parsed.hourOfDay().get(), is(equalTo(12)));
assertThat(parsed.dayOfMonth().get(), is(equalTo(25)));
assertThat(parsed.monthOfYear().get(), is(equalTo(12)));
}
代码示例来源:origin: apache/streams
@Test
public void validCETSubSecond() {
DateTime parsed = parseUTC("2014-12-25T12:00:00.7+01:00");
assertThat(parsed.minuteOfHour().get(), is(equalTo(0)));
assertThat(parsed.hourOfDay().get(), is(equalTo(11)));
assertThat(parsed.dayOfMonth().get(), is(equalTo(25)));
assertThat(parsed.monthOfYear().get(), is(equalTo(12)));
assertThat(parsed.millisOfSecond().get(), is(equalTo(700)));
}
代码示例来源:origin: apache/streams
@Test
public void validCETSubSecondMultidigit() {
DateTime parsed = parseUTC("2014-12-25T12:00:00.7343+01:00");
assertThat(parsed.minuteOfHour().get(), is(equalTo(0)));
assertThat(parsed.hourOfDay().get(), is(equalTo(11)));
assertThat(parsed.dayOfMonth().get(), is(equalTo(25)));
assertThat(parsed.monthOfYear().get(), is(equalTo(12)));
assertThat(parsed.millisOfSecond().get(), is(equalTo(734)));
}
代码示例来源:origin: apache/streams
@Test
public void validESTNoSeparator() {
DateTime parsed = parseUTC("2014-12-25T12:00:00-0500");
assertThat(parsed.minuteOfHour().get(), is(equalTo(0)));
assertThat(parsed.hourOfDay().get(), is(equalTo(17)));
assertThat(parsed.dayOfMonth().get(), is(equalTo(25)));
assertThat(parsed.monthOfYear().get(), is(equalTo(12)));
}
代码示例来源:origin: apache/streams
@Test
public void validUTCMicroSecond() {
DateTime parsed = parseUTC("2014-12-25T12:00:00.235235Z");
assertThat(parsed.minuteOfHour().get(), is(equalTo(0)));
assertThat(parsed.hourOfDay().get(), is(equalTo(12)));
assertThat(parsed.dayOfMonth().get(), is(equalTo(25)));
assertThat(parsed.monthOfYear().get(), is(equalTo(12)));
assertThat(parsed.millisOfSecond().get(), is(equalTo(235)));
}
代码示例来源:origin: apache/streams
@Test
public void validESTSubSecondMultiDigitNoSeparator() {
DateTime parsed = parseUTC("2014-12-25T12:00:00.7343-0500");
assertThat(parsed.minuteOfHour().get(), is(equalTo(0)));
assertThat(parsed.hourOfDay().get(), is(equalTo(17)));
assertThat(parsed.dayOfMonth().get(), is(equalTo(25)));
assertThat(parsed.monthOfYear().get(), is(equalTo(12)));
assertThat(parsed.millisOfSecond().get(), is(equalTo(734)));
}
代码示例来源:origin: apache/streams
@Test
public void validESTSubSecond() {
DateTime parsed = parseUTC("2014-12-25T12:00:00.7-05:00");
assertThat(parsed.minuteOfHour().get(), is(equalTo(0)));
assertThat(parsed.hourOfDay().get(), is(equalTo(17)));
assertThat(parsed.dayOfMonth().get(), is(equalTo(25)));
assertThat(parsed.monthOfYear().get(), is(equalTo(12)));
assertThat(parsed.millisOfSecond().get(), is(equalTo(700)));
}
代码示例来源:origin: apache/streams
@Test
public void validLong() {
DateTime parsed = parseUTC("1419505200734");
assertThat(parsed.minuteOfHour().get(), is(equalTo(0)));
assertThat(parsed.hourOfDay().get(), is(equalTo(11)));
assertThat(parsed.dayOfMonth().get(), is(equalTo(25)));
assertThat(parsed.monthOfYear().get(), is(equalTo(12)));
assertThat(parsed.millisOfSecond().get(), is(equalTo(734)));
}
代码示例来源:origin: org.opencds.cqf/cql-engine
public static DateTime fromJodaDateTime(org.joda.time.DateTime dt) {
int [] values = { dt.year().get(), dt.monthOfYear().get(), dt.dayOfMonth().get(), dt.hourOfDay().get(),
dt.minuteOfHour().get(), dt.secondOfMinute().get(), dt.millisOfSecond().get() };
return new DateTime(new Partial(fields, values), dt.getZone());
}
内容来源于网络,如有侵权,请联系作者删除!