java.time.Month.adjustInto() 方法
描述
java.time.Month.adjustInto(Temporal temporal) 方法将指定的时态对象调整为拥有本月。
声明
以下是 java.time.Month.adjustInto(Temporal temporal) 方法的声明。
public Temporal adjustInto(Temporal temporal)
参数
temporal − 要调整的目标对象,不为空。
返回值
调整后的对象,不为空。
异常
DateTimeException − 如果无法进行调整。
ArithmeticException − 如果发生数字溢出。
示例
下面的例子展示了 java.time.Month.adjustInto(Temporal temporal) 方法的使用。
package com.tutorialspoint;
import java.time.Month;
import java.time.ZonedDateTime;
public class MonthDemo {
public static void main(String[] args) {
ZonedDateTime date = ZonedDateTime.now();
System.out.println(date);
Month month = Month.of(1);
date = (ZonedDateTime)month.adjustInto(date);
System.out.println(date);
}
}
让我们编译并运行上面的程序,这将产生下面的结果 −
2017-03-30T14:20:10.871+05:30[Asia/Calcutta] 2017-01-30T14:20:10.871+05:30[Asia/Calcutta]

