1,转换为String,方法如下:
return dateString;
}
[/code]
2,转换为date
public String convertDateToString(long dateTimes) {
Calendar ca = Calendar.getInstance();
ca.setTimeInMillis(dateTimes);
SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String [code="java"]
dateString = s.format(ca.getTime());
return dateString;
}
[/code]
2,转换为date
public long convertStringToDate(String dateStr) throws ParseException {
SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd");
Calendar ca = Calendar.getInstance();
ca.setTime(s.parse(dateStr));
return ca.getTimeInMillis();
}