集册 Java实例教程 使用月枚举

使用月枚举

欢马劈雪     最近更新时间:2020-01-02 10:19:05

449
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
使用月枚举

import java.time.LocalDate;

import java.time.Month;


public class Main {/** 来 自 时 代      J a v a   公   众 号 - nowjava.com**/

  public static void main(String[] args) {

    // Use Month.JULY as a method argument

    LocalDate ld1 = LocalDate.of(2019, Month.JULY, 1);


    // Derive a Month from a local date

    Month m1 = Month.from(ld1);


    // Create a Month from an int value 2

    Month m2 = Month.of(2);


    // Get the next month from m2

    Month m3 = m2.plus(1);


    // Get the Month from a local date

    Month m4 = ld1.getMonth();
/**来自 nowjava.com**/

    
展开阅读全文