10.9 java

1.构造方法

public Date()     //获取当前的时间

public Date(long date)     //如果参数为零则时间为1970年1月1号

2.常用方法

*public long getTime()    //返回自1970年1月1日00:00:00GMT以来此Date对象表示的毫秒数

public void setTime(long time)   //设置此Date对象,以表示1970年1月1日00:00:00GMT以后 time 毫秒的时间点

//基本事件表示

public class Date1 {
 public static void main(String[] args) {
  long gmt = 0;
  long now = System.currentTimeMillis();
  Date d1 = new Date(gmt);
  Date d2 = new Date(now);
  int y1 = d1.getYear + 1900;
  int y2 = d2.getYear + 1900;
  System.out.println(y1);
  System.out.println(y2);
  long 1 = gmt - 1000 * 60 * 60 * 24;
  Date d3 = new Date(1);
  System.out.println(d3.getYear() + 1900);
  1 = now + 1000 * 60 * 60 * 24;
  Date d4 = new Date(1);
  System.out.println(d4.getYear());
 }
}

 

posted @ 2020-10-09 21:59  鯨落  阅读(128)  评论(0编辑  收藏  举报