long sd=1345185923140L;
Date dat=new Date(sd);
GregorianCalendar gc = new GregorianCalendar();
gc.setTime(dat);
java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String sb=format.format(gc.getTime());
// System.out.println(sb);
//毫秒转换为日期
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
long now = System.currentTimeMillis();
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(now);
System.out.println(now + " = " + formatter.format(calendar.getTime()));
// 日期转换为毫秒 两个日期想减得到天数
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String start="2011-09-20 12:30:45";
String end ="2011-10-20 6:30:00";
//得到毫秒数
long timeEnd = 0;
long timeStart = 0;
try {
timeStart=sdf.parse(start).getTime();
timeEnd = sdf.parse(end).getTime();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//两个日期想减得到天数
long dayCount= (timeEnd-timeStart)/(24*3600*1000);
System.out.println(dayCount);