org.joda.time.LocalDateTime.withMinuteOfHour()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(2.4k)|赞(0)|评价(0)|浏览(182)

本文整理了Java中org.joda.time.LocalDateTime.withMinuteOfHour()方法的一些代码示例,展示了LocalDateTime.withMinuteOfHour()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalDateTime.withMinuteOfHour()方法的具体详情如下:
包路径:org.joda.time.LocalDateTime
类名称:LocalDateTime
方法名:withMinuteOfHour

LocalDateTime.withMinuteOfHour介绍

[英]Returns a copy of this datetime with the minute of hour field updated.

LocalDateTime is immutable, so there are no set methods. Instead, this method returns a new instance with the value of minute of hour changed.
[中]返回此datetime的副本,其中“小时分钟”字段已更新。
LocalDateTime是不可变的,因此没有set方法。相反,此方法返回一个新实例,其值为minute of hour changed。

代码示例

代码示例来源:origin: stackoverflow.com

Date toQuaterOfHour(Date date) {
 LocalDateTime ldt = new LocalDateTime(date.getTime());
 int quater = ldt.getMinuteOfHour() / 15;
 return ldt.withMinuteOfHour(quater * 15).toDate();
}

代码示例来源:origin: itesla/ipst

private boolean matches(HistoKey k, Map<String, Object> map, QueryParams query) {
  if (query.getHorizon() != null && !query.getHorizon().equals(k.getHorizon())) {
    return false;
  }
  if (query.getDayTimeFrom() != null && query.getDayTimeTo() != null) {
    LocalDateTime check = new DateTime(k.getDateTime()).toLocalDateTime();
    LocalDateTime from = new DateTime(query.getDayTimeFrom()).toLocalDateTime();
    LocalDateTime to = new DateTime(query.getDayTimeTo()).toLocalDateTime();
    LocalDateTime start = new DateTime(k.getDateTime()).toLocalDateTime().withHourOfDay(from.getHourOfDay())
        .withMinuteOfHour(from.getMinuteOfHour()).withSecondOfMinute(from.getSecondOfMinute());
    LocalDateTime end = new DateTime(k.getDateTime()).toLocalDateTime().withHourOfDay(to.getHourOfDay())
        .withMinuteOfHour(to.getMinuteOfHour()).withSecondOfMinute(to.getSecondOfMinute());
    if (check.isAfter(end) || check.isBefore(start)) {
      return false;
    }
  }
  if (query.getForecastTime() >= 0) {
    if (k.getForecastDistance() != query.getForecastTime()) {
      return false;
    }
  }
  return true;
}

代码示例来源:origin: org.motechproject/motech-platform-commons-date

public static DateTime newDateTime(LocalDate localDate, int hour, int minute, int second) {
  final DateTimeZone zone = DateTimeSourceUtil.timeZone();
  LocalDateTime localDateTime = new LocalDateTime(zone)
      .withYear(localDate.getYear())
      .withMonthOfYear(localDate.getMonthOfYear())
      .withDayOfMonth(localDate.getDayOfMonth())
      .withHourOfDay(hour)
      .withMinuteOfHour(minute)
      .withSecondOfMinute(second)
      .withMillisOfSecond(0);
  if (zone.isLocalDateTimeGap(localDateTime)) {
    localDateTime = localDateTime.withHourOfDay(hour + 1);
  }
  return localDateTime.toDateTime();
}

相关文章