long time = 1293687000000L; Date date = new Date(time); //20101230T133000 SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddEHHmmss"); System.out.println(sdf.format(date));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); Date date = new Date(); String s = "1293687000000"; long time =Long.parseLong(s); date.setTime(time); String parsetime = sdf.format(date);这个不知道是不是lz要的,可能有点复杂
SlmpertDateFormat df = new SlmpertDateFormat("yyyy/MM/dd");
System.out.println("转换为:" + df.Format(date));
网上有很多关于时间处理的 看一下就会了 很简单的
还可以用Calender类
Date date = new Date(time);
//20101230T133000
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddEHHmmss");
System.out.println(sdf.format(date));
Date date = new Date();
String s = "1293687000000";
long time =Long.parseLong(s);
date.setTime(time);
String parsetime = sdf.format(date);这个不知道是不是lz要的,可能有点复杂
Calendar 是如何使用,你还是自己查一下资料吧
+1,日期的比较也是通过转为long 行进行比较的,
Date 对象有个 getTime() 的方法获取的是Date 对象 至 1970年1月1日 的毫秒数
// TODO Auto-generated method stub
long timeLong = 1293687000000L;
Calendar cal = Calendar.getInstance(TimeZone
.getTimeZone("Asia/Shanghai"));
cal.setTimeInMillis(timeLong);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
String timeStr = sdf.format(cal.getTime());
System.out.println(timeStr);
}运行结果:2010-12-30 13-30-00
很简单只要执行过一次就会了
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
String timeStr = sdf.format(date);///