时间转换的相关代码
public static long dateToLong (String in) {
// 将日期转成毫秒 yyyy-MM-dd HH:mm:ss 2014-5
SimpleDateFormat format = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”);
// String systimeString =com.alipay.util.UtilDate.getDateFormatter();
java.util.Date date2;
Calendar cal = Calendar.getInstance();
try {
date2 = format.parse(in);
cal.setTime(date2);
} catch (ParseException e) {
e.printStackTrace();
}
return cal.getTimeInMillis();
}
// 将毫秒转成日期 yyyy-MM-dd HH:mm:ss 2014-5
public static String longToDate (long in) {
SimpleDateFormat format = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”);
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(in);
String dateString = format.format(calendar.getTime());
// System.out.println(“longToDate: long:”+ in +” date:”+ dateString);
return dateString;
}