package com.heilong.date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class Demo1{
public static void main(String[] args) throws ParseException {
Calendar calendar = Calendar.getInstance();
System.out.println("年:" + calendar.get(Calendar.YEAR));
System.out.println("月:" + (calendar.get(calendar.MONTH)+1));
System.out.println("日:" + calendar.get(calendar.DATE));
System.out.println("时:" + calendar.get(calendar.HOUR_OF_DAY));
System.out.println("分:" + calendar.get(calendar.MINUTE));
System.out.println("秒:" + calendar.get(calendar.SECOND));
Date date = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
String time = dateFormat.format(date);
System.out.println("当前的系统时间:" + time);
String birthday = "2020年10月25日 11:11:11";
Date date2 = dateFormat.parse(birthday);
System.out.println(date2);
}
}