输出系统当前时间

1.  从GMT(格林尼治标准时间)1970年, 1 月 1日00:00:00这一刻之后经历的毫秒数.

      import java.util.Date;
public class DateExample1{
  public static void main(String[] args)
 {
  Date date=new Date();
  System.out.println(date.getTime());
  }
}


2  输出日期数据的定制格式

   import java.util.text.SimpleDateFormat;
import java.util.Date;
public class DateExample2{
  public static void main(String[] args)
 {
  SimpleDateFormat bartDateFormat=new SimpleDateFormat("EEEE-MMMM-dd-yyyy");
  Date date=new Date();
  System.out.println(bartDateFormat.format(date));
  }
}

你可能感兴趣的:(输出系统当前时间)