java.time.MonthDay.adjustInto() 方法示例



說明

java.time.MonthDay.adjustInto(Temporal temporal) 方法調整指定的時間物件以獲取此月天。

宣告

以下是 java.time.MonthDay.adjustInto(Temporal temporal) 方法的宣告。

public Temporal adjustInto(Temporal temporal)

```java

引數

temporal - 要調整的目標物件,不能為空。

返回值

調整後的物件(非 null)。

  • 異常

  • DateTimeException - 如果無法進行調整。

ArithmeticException - 如果發生數值溢位。

示例

package com.tutorialspoint;

import java.time.MonthDay;
import java.time.ZonedDateTime;

public class MonthDayDemo {
   public static void main(String[] args) {

      ZonedDateTime date = ZonedDateTime.now();
      System.out.println(date);  

      MonthDay date1 = MonthDay.parse("--12-30");
      date = (ZonedDateTime)date1.adjustInto(date);
      System.out.println(date);  
   }
}

即時演示

2017-03-20T15:29:58.470+05:30[Asia/Calcutta]
2017-12-30T15:29:58.470+05:30[Asia/Calcutta]
列印頁面