java.time.Clock.offset() 方法示例


java.time.Clock.offset() 方法示例

package com.codingdict;

import java.time.Clock;
import java.time.Duration;

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

      Clock clock = Clock.systemUTC();  
      Duration duration = Duration.ofHours(5);  
      Clock clock1 = Clock.offset(clock, duration);   
      System.out.println("Clock 1: " + clock.instant());
      System.out.println("Clock 2: " + clock1.instant());
   }
}