本文整理了Java中org.joda.time.DateTime.withMinuteOfHour()
方法的一些代码示例,展示了DateTime.withMinuteOfHour()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DateTime.withMinuteOfHour()
方法的具体详情如下:
包路径:org.joda.time.DateTime
类名称:DateTime
方法名:withMinuteOfHour
[英]Returns a copy of this datetime with the minute of hour updated.
DateTime is immutable, so there are no set methods. Instead, this method returns a new instance with the value of minute of hour changed.
[中]返回此datetime的副本,并更新小时分钟数。
DateTime是不可变的,因此没有set方法。相反,此方法返回一个新实例,其值为minute of hour changed。
代码示例来源:origin: Graylog2/graylog2-server
private static DateTime getDayBucket(DateTime observationTime) {
return observationTime.withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0);
}
代码示例来源:origin: azkaban/azkaban
private DateTime parseDateTime(final String scheduleDate, final String scheduleTime) {
// scheduleTime: 12,00,pm,PDT
final String[] parts = scheduleTime.split(",", -1);
int hour = Integer.parseInt(parts[0]);
final int minutes = Integer.parseInt(parts[1]);
final boolean isPm = parts[2].equalsIgnoreCase("pm");
final DateTimeZone timezone =
parts[3].equals("UTC") ? DateTimeZone.UTC : DateTimeZone.getDefault();
// scheduleDate: 02/10/2013
DateTime day = null;
if (scheduleDate == null || scheduleDate.trim().length() == 0) {
day = new LocalDateTime().toDateTime();
} else {
day = DateTimeFormat.forPattern("MM/dd/yyyy")
.withZone(timezone).parseDateTime(scheduleDate);
}
hour %= 12;
if (isPm) {
hour += 12;
}
final DateTime firstSchedTime =
day.withHourOfDay(hour).withMinuteOfHour(minutes).withSecondOfMinute(0);
return firstSchedTime;
}
代码示例来源:origin: apache/incubator-pinot
case MINUTES:
_dateTimeTruncate = (dateTime) -> _outputDateTimeFormatter
.print(dateTime.withMinuteOfHour((dateTime.getMinuteOfHour() / sz) * sz).minuteOfHour().roundFloorCopy());
break;
case HOURS:
代码示例来源:origin: kairosdb/kairosdb
case SECONDS:
dt = dt.withHourOfDay(0);
dt = dt.withMinuteOfHour(0);
dt = dt.withSecondOfMinute(0);
default:
代码示例来源:origin: stackoverflow.com
DateTime dt = new DateTime(1385577373517L, DateTimeZone.UTC);
// Prints 2013-11-27T18:36:13.517Z
System.out.println(dt);
// Prints 2013-11-27T18:36:00.000Z (Floor rounded to a minute)
System.out.println(dt.minuteOfDay().roundFloorCopy());
// Prints 2013-11-27T18:30:00.000Z (Rounded to custom minute Window)
int windowMinutes = 10;
System.out.println(
dt.withMinuteOfHour((dt.getMinuteOfHour() / windowMinutes) * windowMinutes)
.minuteOfDay().roundFloorCopy()
);
代码示例来源:origin: rackerlabs/blueflood
private DateTime extractAndUpdateTime(DateTime inputDateTime) {
DateTime resultDateTime = inputDateTime.withSecondOfMinute(0).withMillisOfSecond(0);
if (dateTime.equals("") || dateTime.contains("now"))
return resultDateTime;
int hour = 0;
int minute = 0;
Pattern p = Pattern.compile("(\\d{1,2}):(\\d{2})([a|p]m)?(.*)");
Matcher m = p.matcher(dateTime);
if (m.matches()) {
hour = Integer.parseInt(m.group(1));
minute = Integer.parseInt(m.group(2));
String middayModifier = m.group(3);
if (middayModifier != null && middayModifier.equals("pm"))
hour = (hour + 12) % 24;
dateTime = m.group(4);
}
if (dateTime.contains("noon")) {
hour = 12;
dateTime = dateTime.replace("noon", "");
}
else if (dateTime.contains("teatime")) {
hour = 16;
dateTime = dateTime.replace("teatime", "");
} else if (dateTime.contains("midnight"))
dateTime = dateTime.replace("midnight", "");
return resultDateTime.withHourOfDay(hour).withMinuteOfHour(minute);
}
代码示例来源:origin: prestodb/presto
assertFunction("date_trunc('minute', " + TIMESTAMP_LITERAL + ")", TimestampType.TIMESTAMP, sqlTimestampOf(result, session));
result = result.withMinuteOfHour(0);
assertFunction("date_trunc('hour', " + TIMESTAMP_LITERAL + ")", TimestampType.TIMESTAMP, sqlTimestampOf(result, session));
assertFunction("date_trunc('minute', " + WEIRD_TIMESTAMP_LITERAL + ")", TIMESTAMP_WITH_TIME_ZONE, toTimestampWithTimeZone(result));
result = result.withMinuteOfHour(0);
assertFunction("date_trunc('hour', " + WEIRD_TIMESTAMP_LITERAL + ")", TIMESTAMP_WITH_TIME_ZONE, toTimestampWithTimeZone(result));
代码示例来源:origin: rackerlabs/blueflood
@Test
public void testHourMinuteKeywords() {
String noonTimestamp = "noon";
String teatimeTimestamp = "teatime";
String midnightTimestamp = "midnight";
Assert.assertEquals(DateTimeParser.parse(noonTimestamp),
referenceDateTime().withHourOfDay(12).withMinuteOfHour(0));
Assert.assertEquals(DateTimeParser.parse(teatimeTimestamp),
referenceDateTime().withHourOfDay(16).withMinuteOfHour(0));
Assert.assertEquals(DateTimeParser.parse(midnightTimestamp),
referenceDateTime().withHourOfDay(0).withMinuteOfHour(0));
}
代码示例来源:origin: rackerlabs/blueflood
private static DateTime referenceDateTime() {
return new DateTime().withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0);
}
代码示例来源:origin: rackerlabs/blueflood
@Test
public void testRegularHourMinute() {
String hourMinuteTimestamp = "12:24";
String hourMinuteWithAm = "9:13am";
String hourMinuteWithPm = "09:13pm";
Assert.assertEquals(DateTimeParser.parse(hourMinuteTimestamp),
referenceDateTime().withHourOfDay(12).withMinuteOfHour(24));
Assert.assertEquals(DateTimeParser.parse(hourMinuteWithAm),
referenceDateTime().withHourOfDay(9).withMinuteOfHour(13));
Assert.assertEquals(DateTimeParser.parse(hourMinuteWithPm),
referenceDateTime().withHourOfDay(21).withMinuteOfHour(13));
}
代码示例来源:origin: rackerlabs/blueflood
@Test
public void testComplexFormats() {
testFormat("12:24 yesterday", nowDateTime().minusDays(1).withHourOfDay(12).withMinuteOfHour(24));
testFormat("12:24 tomorrow", nowDateTime().plusDays(1).withHourOfDay(12).withMinuteOfHour(24));
testFormat("12:24 today", nowDateTime().withHourOfDay(12).withMinuteOfHour(24));
testFormat("noon 12/30/2014", nowDateTime().withDate(2014, 12, 30).withHourOfDay(12).withMinuteOfHour(0));
int currentYear = referenceDateTime().getYear();
testFormat("15:45 12/30/14", new DateTime(2014, 12, 30, 15, 45, 0, 0));
testFormat("teatime 12/30/2014", new DateTime(2014, 12, 30, 16, 0, 0, 0));
testFormat("midnight Jul 30", new DateTime(currentYear, 07, 30, 0, 0, 0, 0));
testFormat("Jul 30, 2013", new DateTime(2013, 07, 30, 0, 0, 0, 0));
testFormat("Jul 30", new DateTime(currentYear, 07, 30, 0, 0, 0, 0));
testFormat("20141230", new DateTime(2014, 12, 30, 0, 0, 0, 0));
}
代码示例来源:origin: openimaj/openimaj
@Override
public LongLongPair startEnd(long time) {
DateTime dt = new DateTime(time);
DateTime start = dt.withMinuteOfHour(0);
DateTime end = dt.plus(hourPeriod).withMinuteOfHour(0);
return LongLongPair.pair(start.getMillis(), end.getMillis());
}
},MINUTE {
代码示例来源:origin: io.virtdata/virtdata-lib-realer
@Override
public long applyAsLong(long operand) {
return new DateTime(operand,tz).withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0).getMillis();
}
}
代码示例来源:origin: plusonelabs/calendar-widget
public static Intent createNewEventIntent(DateTimeZone timeZone) {
DateTime beginTime = new DateTime(timeZone).plusHours(1).withMinuteOfHour(0).withSecondOfMinute(0)
.withMillisOfSecond(0);
DateTime endTime = beginTime.plusHours(1);
return new Intent(Intent.ACTION_INSERT, Events.CONTENT_URI)
.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, beginTime.getMillis())
.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime.getMillis());
}
}
代码示例来源:origin: qcadoo/mes
private Interval extractSearchInterval(final Entity contextEntity) {
Date from = contextEntity.getDateField(BalanceContextFields.FROM_DATE);
Date to = contextEntity.getDateField(BalanceContextFields.TO_DATE);
DateTime toMidnight = new DateTime(to).withHourOfDay(23).withMinuteOfHour(59).withSecondOfMinute(59);
return new Interval(new DateTime(from), toMidnight);
}
代码示例来源:origin: apiman/apiman
/**
* Parse the to date query param.
*/
private DateTime parseFromDate(String fromDate) {
// Default to the last 30 days
DateTime defaultFrom = new DateTime().withZone(DateTimeZone.UTC).minusDays(30).withHourOfDay(0)
.withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0);
return parseDate(fromDate, defaultFrom, true);
}
代码示例来源:origin: qcadoo/mes
private Optional<DateTime> getShiftStartDate(DateTime day, Entity shift) {
Shift shiftFirst = new Shift(shift);
List<TimeRange> ranges = shiftFirst.findWorkTimeAt(day.toLocalDate());
if (ranges.isEmpty()) {
return Optional.empty();
}
LocalTime startTime = ranges.get(0).getFrom();
DateTime startShitTime = day;
startShitTime = startShitTime.withHourOfDay(startTime.getHourOfDay());
startShitTime = startShitTime.withMinuteOfHour(startTime.getMinuteOfHour());
return Optional.of(startShitTime);
}
代码示例来源:origin: io.apiman/apiman-manager-api-rest-impl
/**
* Parse the to date query param.
*/
private DateTime parseFromDate(String fromDate) {
// Default to the last 30 days
DateTime defaultFrom = new DateTime().withZone(DateTimeZone.UTC).minusDays(30).withHourOfDay(0)
.withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0);
return parseDate(fromDate, defaultFrom, true);
}
代码示例来源:origin: blocoio/faker
private DateTime randomTime(DateTime dateTime, Period period) {
return dateTime.withHourOfDay(hours(period))
.withMinuteOfHour(minutes())
.withSecondOfMinute(seconds());
}
代码示例来源:origin: org.jasig.portlet/blackboardvc-portlet-api
@Future
@FutureWithYearLimit()
public DateTime getStartTime() {
return startDate.toDateTime().withHourOfDay(startHourMinute.getHourOfDay()).withMinuteOfHour(startHourMinute.getMinuteOfHour());
}
内容来源于网络,如有侵权,请联系作者删除!