我的数据库存储时间为DateTime,按照String取出来,转为时间戳(具体类型,可自行定义):
public static Long dateToStamp(String s) throws ParseException {
String res;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" );
Date date = simpleDateFormat.parse(s);
long ts = date.getTime();
return ts;
}
时间戳转为时间
//时间戳转换为时间
public static String stampToDate(Long s){
SimpleDateFormat sdf= new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" );
String strTime = sdf.format(s);
return strTime;
}


