package com.Cx_330.run;
import org.junit.Test;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Calendar;
import java.util.Date;
public class CCC {
public static void main(String[] args) {
Date date = new Date();
System.out.println(date);
System.out.println(date.getTime());
System.out.println("#########################");
Calendar calendar = Calendar.getInstance();
System.out.println(calendar.getTime());
System.out.println(calendar.get(Calendar.YEAR));
System.out.println("-------------------------");
LocalDate now = LocalDate.now();
System.out.println(now);
System.out.println(now.getYear());
System.out.println(now.getDayOfYear());
System.out.println(now.getDayOfWeek());
System.out.println(170.0/30);
System.out.println("-------------------------");
LocalTime time=LocalTime.now();
System.out.println(time);
System.out.println(time.getHour());
System.out.println("-------------------------");
LocalDateTime l=LocalDateTime.now();
System.out.println(l);
System.out.println(l.toLocalDate());
System.out.println(l.toLocalTime());
}
}
Java中日期时间的主要API示范
最新推荐文章于 2024-11-11 21:19:25 发布