java.time.OffsetDateTime.plusHours()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(222)

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

OffsetDateTime.plusHours介绍

[英]Returns a copy of this OffsetDateTime with the specified period in hours added.

This instance is immutable and unaffected by this method call.
[中]返回此OffsetDateTime的副本,并添加指定的时间段(以小时为单位)。
此实例是不可变的,不受此方法调用的影响。

代码示例

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

  1. /**
  2. * Returns a copy of this {@code OffsetDateTime} with the specified period in hours subtracted.
  3. * <p>
  4. * This instance is immutable and unaffected by this method call.
  5. *
  6. * @param hours the hours to subtract, may be negative
  7. * @return an {@code OffsetDateTime} based on this date-time with the hours subtracted, not null
  8. * @throws DateTimeException if the result exceeds the supported date range
  9. */
  10. public OffsetDateTime minusHours(long hours) {
  11. return (hours == Long.MIN_VALUE ? plusHours(Long.MAX_VALUE).plusHours(1) : plusHours(-hours));
  12. }

代码示例来源:origin: Netflix/iceberg

  1. static String humanHour(int hourOrdinal) {
  2. OffsetDateTime time = EPOCH.plusHours(hourOrdinal);
  3. return String.format("%04d-%02d-%02d-%02d",
  4. time.getYear(), time.getMonth().getValue(), time.getDayOfMonth(), time.getHour());
  5. }

代码示例来源:origin: org.openbase.bco/ontology.lib

  1. /**
  2. * Method adds/subtracts time from the current dateTime.
  3. *
  4. * @param minutes are the minutes.
  5. * @param hours are the hours.
  6. * @param days are the days.
  7. * @param months are the months.
  8. * @param years are the years.
  9. * @return the changed dateTime as String.
  10. */
  11. public static String addTimeToCurrentDateTime(final int minutes, final int hours, final int days, final int months, final int years) {
  12. final OffsetDateTime now = OffsetDateTime.now();
  13. now.plusMinutes(minutes);
  14. now.plusHours(hours);
  15. now.plusDays(days);
  16. now.plusMonths(months);
  17. now.plusYears(years);
  18. return now.toString();
  19. }
  20. }

代码示例来源:origin: adorsys/xs2a

  1. private List<SinglePayment> mapBulkPaymentToSinglePayments(BulkPaymentInitiationSctJson paymentRequest) {
  2. return paymentRequest.getPayments().stream()
  3. .map(p -> {
  4. SinglePayment payment = new SinglePayment();
  5. payment.setDebtorAccount(mapToXs2aAccountReference(paymentRequest.getDebtorAccount()));
  6. payment.setRequestedExecutionDate(paymentRequest.getRequestedExecutionDate());
  7. payment.setEndToEndIdentification(p.getEndToEndIdentification());
  8. payment.setUltimateDebtor("NOT SUPPORTED");
  9. payment.setInstructedAmount(amountModelMapper.mapToXs2aAmount(p.getInstructedAmount()));
  10. payment.setCreditorAccount(mapToXs2aAccountReference(p.getCreditorAccount()));
  11. payment.setCreditorAgent(p.getCreditorAgent());
  12. payment.setCreditorName(p.getCreditorName());
  13. payment.setCreditorAddress(accountModelMapper.mapToXs2aAddress(p.getCreditorAddress()));
  14. payment.setUltimateCreditor(null);
  15. payment.setPurposeCode(new Xs2aPurposeCode(null));
  16. payment.setRemittanceInformationUnstructured(p.getRemittanceInformationUnstructured());
  17. payment.setRemittanceInformationStructured(new Remittance());
  18. payment.setRequestedExecutionTime(OffsetDateTime.now().plusHours(1));
  19. return payment;
  20. })
  21. .collect(Collectors.toList());
  22. }

代码示例来源:origin: de.adorsys.psd2/xs2a-impl

  1. private List<SinglePayment> mapBulkPaymentToSinglePayments(BulkPaymentInitiationSctJson paymentRequest) {
  2. return paymentRequest.getPayments().stream()
  3. .map(p -> {
  4. SinglePayment payment = new SinglePayment();
  5. payment.setDebtorAccount(mapToXs2aAccountReference(paymentRequest.getDebtorAccount()));
  6. payment.setRequestedExecutionDate(paymentRequest.getRequestedExecutionDate());
  7. payment.setEndToEndIdentification(p.getEndToEndIdentification());
  8. payment.setUltimateDebtor("NOT SUPPORTED");
  9. payment.setInstructedAmount(amountModelMapper.mapToXs2aAmount(p.getInstructedAmount()));
  10. payment.setCreditorAccount(mapToXs2aAccountReference(p.getCreditorAccount()));
  11. payment.setCreditorAgent(p.getCreditorAgent());
  12. payment.setCreditorName(p.getCreditorName());
  13. payment.setCreditorAddress(accountModelMapper.mapToXs2aAddress(p.getCreditorAddress()));
  14. payment.setUltimateCreditor(null);
  15. payment.setPurposeCode(new Xs2aPurposeCode(null));
  16. payment.setRemittanceInformationUnstructured(p.getRemittanceInformationUnstructured());
  17. payment.setRemittanceInformationStructured(new Remittance());
  18. payment.setRequestedExecutionTime(OffsetDateTime.now().plusHours(1));
  19. return payment;
  20. })
  21. .collect(Collectors.toList());
  22. }

代码示例来源:origin: de.adorsys.psd2/xs2a-impl

  1. private PeriodicPayment mapToXs2aPeriodicPayment(PeriodicPaymentInitiationSctJson paymentRequest) {
  2. PeriodicPayment payment = new PeriodicPayment();
  3. payment.setEndToEndIdentification(paymentRequest.getEndToEndIdentification());
  4. payment.setDebtorAccount(mapToXs2aAccountReference(paymentRequest.getDebtorAccount()));
  5. payment.setUltimateDebtor("NOT SUPPORTED");
  6. payment.setInstructedAmount(amountModelMapper.mapToXs2aAmount(paymentRequest.getInstructedAmount()));
  7. payment.setCreditorAccount(mapToXs2aAccountReference(paymentRequest.getCreditorAccount()));
  8. payment.setCreditorAgent(paymentRequest.getCreditorAgent());
  9. payment.setCreditorName(paymentRequest.getCreditorName());
  10. payment.setCreditorAddress(accountModelMapper.mapToXs2aAddress(paymentRequest.getCreditorAddress()));
  11. payment.setUltimateCreditor(paymentRequest.getCreditorName());
  12. payment.setPurposeCode(new Xs2aPurposeCode("N/A"));
  13. payment.setRemittanceInformationUnstructured(paymentRequest.getRemittanceInformationUnstructured());
  14. payment.setRemittanceInformationStructured(new Remittance());
  15. payment.setRequestedExecutionDate(LocalDate.now());
  16. payment.setRequestedExecutionTime(OffsetDateTime.now().plusHours(1));
  17. payment.setStartDate(paymentRequest.getStartDate());
  18. payment.setExecutionRule(mapToPisExecutionRule(paymentRequest.getExecutionRule()).orElse(null));
  19. payment.setEndDate(paymentRequest.getEndDate());
  20. payment.setFrequency(mapToXs2aFrequencyCode(paymentRequest.getFrequency()));
  21. payment.setDayOfExecution(mapToPisDayOfExecution(paymentRequest.getDayOfExecution()).orElse(null));
  22. return payment;
  23. }

代码示例来源:origin: adorsys/xs2a

  1. private PeriodicPayment mapToXs2aPeriodicPayment(PeriodicPaymentInitiationSctJson paymentRequest) {
  2. PeriodicPayment payment = new PeriodicPayment();
  3. payment.setEndToEndIdentification(paymentRequest.getEndToEndIdentification());
  4. payment.setDebtorAccount(mapToXs2aAccountReference(paymentRequest.getDebtorAccount()));
  5. payment.setUltimateDebtor("NOT SUPPORTED");
  6. payment.setInstructedAmount(amountModelMapper.mapToXs2aAmount(paymentRequest.getInstructedAmount()));
  7. payment.setCreditorAccount(mapToXs2aAccountReference(paymentRequest.getCreditorAccount()));
  8. payment.setCreditorAgent(paymentRequest.getCreditorAgent());
  9. payment.setCreditorName(paymentRequest.getCreditorName());
  10. payment.setCreditorAddress(accountModelMapper.mapToXs2aAddress(paymentRequest.getCreditorAddress()));
  11. payment.setUltimateCreditor(paymentRequest.getCreditorName());
  12. payment.setPurposeCode(new Xs2aPurposeCode("N/A"));
  13. payment.setRemittanceInformationUnstructured(paymentRequest.getRemittanceInformationUnstructured());
  14. payment.setRemittanceInformationStructured(new Remittance());
  15. payment.setRequestedExecutionDate(LocalDate.now());
  16. payment.setRequestedExecutionTime(OffsetDateTime.now().plusHours(1));
  17. payment.setStartDate(paymentRequest.getStartDate());
  18. payment.setExecutionRule(mapToPisExecutionRule(paymentRequest.getExecutionRule()).orElse(null));
  19. payment.setEndDate(paymentRequest.getEndDate());
  20. payment.setFrequency(mapToXs2aFrequencyCode(paymentRequest.getFrequency()));
  21. payment.setDayOfExecution(mapToPisDayOfExecution(paymentRequest.getDayOfExecution()).orElse(null));
  22. return payment;
  23. }

相关文章