about time

package com.API;

import java.util.Calendar;
import java.util.Date;

public class TestTime {
public static void main(String[] args) {
//Date日期
//Calendar 日历
Date date = new Date();
//当前的系统时间
System.out.println(date);
System.out.println(date.getYear());
System.out.println(date.getMonth());
//重点
//set 设置时间
//get 获取时间
System.out.println(date.getTime());
Calendar instance = Calendar.getInstance();
System.out.println(instance);
System.out.println(instance.get(Calendar.YEAR));
System.out.println(instance.get(Calendar.MONTH) + 1);
System.out.println(instance.get(Calendar.DATE));
System.out.println(instance.get(Calendar.HOUR_OF_DAY));
System.out.println(instance.get(Calendar.MINUTE));

}
}
posted @ 2022-05-13 09:59  小松2739  阅读(111)  评论(0编辑  收藏  举报