/**
* 时间工具类
*/publicclassDateUtil{privatestaticSimpleDateFormat sf =null;/**
* 获取系统时间
*/publicstaticStringgetCurrentDate(){Date d =newDate();
sf =newSimpleDateFormat("yyyy-MM-dd HH:mm:ss");return sf.format(d);}/**
* 时间戳转换成字符串
*/publicstaticStringgetDateToString(long time){Date d =newDate(time);
sf =newSimpleDateFormat("yyyy-MM-dd HH:mm:ss");return sf.format(d);}/**
* 将字符串转为时间戳
*/publicstaticlonggetStringToDate(String time){
sf =newSimpleDateFormat("yyyy-MM-dd HH:mm:ss");Date date =newDate();try{
date = sf.parse(time);}catch(ParseException e){
e.printStackTrace();}return date.getTime();}/**
* 直接获取时间戳
*/publicstaticStringgetTimeStamp(){String currentDate =getCurrentDate();
sf =newSimpleDateFormat("yyyy-MM-dd HH:mm:ss");Date date =newDate();try{
date = sf.parse(currentDate);}catch(ParseException e){
e.printStackTrace();}returnString.valueOf(date.getTime());}}