Java 8中获取年、月、日信息
package com.shxt.demo02; import java.time.LocalDate; public class Demo02 { public static void main(String[] args) { LocalDate today = LocalDate.now(); int year = today.getYear(); int month = today.getMonthValue(); int day = today.getDayOfMonth(); System.out.println("year:"+year); System.out.println("month:"+month); System.out.println("day:"+day); } }
Atas ialah kandungan terperinci Java8中如何获取年、月、日信息. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!