java.time.Duration.plusDays()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(192)

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

Duration.plusDays介绍

[英]Returns a copy of this duration with the specified duration in 24 hour days added.

This instance is immutable and unaffected by this method call.
[中]返回此持续时间的副本,并添加指定的24小时内持续时间。
此实例是不可变的,不受此方法调用的影响。

代码示例

代码示例来源:origin: com.github.seratch/java-time-backport

/**
 * Returns a copy of this duration with the specified duration in 24 hour days subtracted.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param daysToSubtract  the days to subtract, positive or negative
 * @return a {@code Duration} based on this duration with the specified days subtracted, not null
 * @throws ArithmeticException if numeric overflow occurs
 */
public Duration minusDays(long daysToSubtract) {
  return (daysToSubtract == Long.MIN_VALUE ? plusDays(Long.MAX_VALUE).plusDays(1) : plusDays(-daysToSubtract));
}

代码示例来源:origin: yescallop/EssentialsNK

switch (c1) {
  case '纪':
    unit = unit.plusDays(36500);
    break;
  case '年':
    unit = unit.plusDays(365);
    break;
  case '月':
    unit = unit.plusDays(30);
    break;
  case '周':
    unit = unit.plusDays(7);
    break;
  case '日':
    unit = unit.plusDays(1);
    break;
  case '时':

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

Duration fromMorning = Duration.between(morning, time);
Duration toEvening = Duration.between(evening, time);
if(fromMorning.isNegative()) toEvening=toEvening.plusDays(1);
else if(!toEvening.isNegative()) fromMorning=fromMorning.minusDays(1);
l1.setText(format(fromMorning, "morning"));

代码示例来源:origin: yescallop/EssentialsNK

public boolean mute(Player player, int d, int h, int m, int s) {
  return this.mute(player, Duration.ZERO.plusDays(d).plusHours(h).plusMinutes(m).plusSeconds(s));
}

代码示例来源:origin: yescallop/EssentialsNK

public String getMuteTimeMessage(int d, int h, int m, int s) {
  return getDurationString(Duration.ZERO.plusDays(d).plusHours(h).plusMinutes(m).plusSeconds(s));
}

代码示例来源:origin: platonai/pulsar

@Test
public void testDuration() {
  Instant epoch = Instant.EPOCH;
  Instant now = Instant.now();
  Duration gap = Duration.between(epoch, now);
  System.out.println(gap.toDays());
  System.out.println(gap);
  long days = ChronoUnit.DAYS.between(epoch, now);
  System.out.println(days);
  System.out.println(Duration.ofDays(365 * 100).getSeconds());
  System.out.println(Duration.ofMinutes(60).toMillis());
  System.out.println(DurationFormatUtils.formatDuration(gap.toMillis(), "d\' days \'H\' hours \'m\' minutes \'s\' seconds\'"));
  System.out.println(DurationFormatUtils.formatDuration(gap.toMillis(), "d\'days\' H:mm:ss"));
  Duration durationToMidnight = Duration.between(LocalDateTime.now().truncatedTo(ChronoUnit.DAYS), LocalDateTime.now());
  System.out.println(durationToMidnight.plusDays(1));
  assertEquals(Duration.ofSeconds(1), DateTimeUtil.parseDuration("PT1S", Duration.ZERO));
}

代码示例来源:origin: org.hibernate.validator/hibernate-validator

@Override
public void initialize(DurationMin constraintAnnotation) {
  this.minDuration = Duration.ofNanos( constraintAnnotation.nanos() )
      .plusMillis( constraintAnnotation.millis() )
      .plusSeconds( constraintAnnotation.seconds() )
      .plusMinutes( constraintAnnotation.minutes() )
      .plusHours( constraintAnnotation.hours() )
      .plusDays( constraintAnnotation.days() );
  this.inclusive = constraintAnnotation.inclusive();
}

代码示例来源:origin: org.hibernate.validator/hibernate-validator

@Override
public void initialize(DurationMax constraintAnnotation) {
  this.maxDuration = Duration.ofNanos( constraintAnnotation.nanos() )
      .plusMillis( constraintAnnotation.millis() )
      .plusSeconds( constraintAnnotation.seconds() )
      .plusMinutes( constraintAnnotation.minutes() )
      .plusHours( constraintAnnotation.hours() )
      .plusDays( constraintAnnotation.days() );
  this.inclusive = constraintAnnotation.inclusive();
}

代码示例来源:origin: yescallop/EssentialsNK

.plusDays(Integer.parseInt(args[1]))
.plusHours(Integer.parseInt(args[2]))
.plusMinutes(Integer.parseInt(args[3]))

代码示例来源:origin: kiegroup/optaweb-employee-rostering

public ShiftTemplateView(Integer rotationLength, ShiftTemplate shiftTemplate) {
  super(shiftTemplate);
  this.spotId = shiftTemplate.getSpot().getId();
  this.rotationEmployeeId = (shiftTemplate.getRotationEmployee() != null) ? shiftTemplate.getRotationEmployee().getId() : null;
  this.durationBetweenRotationStartAndTemplateStart = Duration
      .ofDays(shiftTemplate.getStartDayOffset()).plusSeconds(shiftTemplate
          .getStartTime().toSecondOfDay());
  this.shiftTemplateDuration = Duration
      .ofDays((shiftTemplate.getEndDayOffset() < shiftTemplate.getStartDayOffset()) ? rotationLength : 0)
      .plusDays(shiftTemplate.getEndDayOffset() - shiftTemplate.getStartDayOffset())
      .plusSeconds(shiftTemplate.getEndTime().toSecondOfDay())
      .minusSeconds(shiftTemplate.getStartTime().toSecondOfDay());
}

相关文章