java.time.ZoneOffset.compareTo() 方法示例


java.time.ZoneOffset.compareTo() 方法示例

package com.codingdict;

import java.time.ZoneOffset;

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

      ZoneOffset zoneOffset = ZoneOffset.of("Z");
      System.out.println("ZoneOffset #1: " + zoneOffset);  

      ZoneOffset zoneOffset1 = ZoneOffset.of("+02:00");
      System.out.println("ZoneOffset #2: " + zoneOffset1);  

      int result = zoneOffset.compareTo(zoneOffset1);
      System.out.println(result > 1 ? "ZoneOffset #1 is greater than ZoneOffset #2."
         :"ZoneOffset #2 is greater than ZoneOffset #1.");  
   }
}