package com.neusoft.test1;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class Test1 {
public static void main(String[] args) throws ParseException {
// TODO Auto-generated method stub
// System.out.println(d1);
method4();
}
// 日期与字符串类型转换
public static void method4() throws ParseException {
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
// System.out.println(new Date());
// 日期 ---->字符串
System.out.println(sdf.format(new Date()));
//字符串------>日期
System.out.println(sdf.parse("2018-08-19 11-09-17"));
}
public static void method3(){
System.out.println(Calendar.getInstance());
System.out.println( Calendar.getInstance().get(Calendar.DAY_OF_WEEK));
System.out.println(Calendar.getInstance().get(Calendar.DATE));
System.out.println(Calendar.getInstance().get(Calendar.DAY_OF_MONTH));
Calendar c=Calendar.getInstance();
c.set(2018, 8, 19);
System.out.println(c);
System.out.println(c.get(Calendar.YEAR));
}
public static void method2() {
System.out.println(System.currentTimeMillis());
System.out.println(new Date(1566182853000l));
}
public static void method1() {
Date d1=new Date();
System.out.println(d1);
System.out.println(d1.getDate());
System.out.println(d1.getTime());
Date d2=new Date(1566182567644l);
System.out.println(d2);
Date d3=new Date(0l);
System.out.println(d3);
System.out.println(d1.before(d2));
System.out.println(d1.compareTo(d2));
Date d4=new Date(0l);
Date d5=new Date(0l);
System.out.println(d4.compareTo(d5));
System.out.println(d4.equals(d5));
}
}