java.time.Period.parse() 方法示例


java.time.Period.parse() 方法示例

package com.codingdict;

import java.time.Period;

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

      Period period = Period.parse("P1Y2M3D");
      System.out.println("Years: " + period.getYears()
         + ", Months: " + period.getMonths()
         +", Days: " + period.getDays());          
   }
}