日期练习
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; /* * 1、打印格林尼治时间 * 2、打印默认时间格式 * 3、新建时间格式 * 4、算过去时间与现在时间的天数 */
public class DateDemo { public static void main(String args[]) throws Exception{ Date d=new Date(); System.out.println(d); System.out.println(d.getTime()); SimpleDateFormat f=new SimpleDateFormat(“yyyy-MM-dd”); System.out.println(f.format(d)); Date d1=f.parse(“1993-03-05”); double c=(d.getTime()-d1.getTime())/(1000*24*60*60); System.out.println(c);
}
}
转载请注明原文地址: https://ju.6miu.com/read-24283.html