Organize a time Stamp tool class
Import Java.text.parseexception;import Java.text.simpledateformat;import Java.util.date;public class DateUtil { private static SimpleDateFormat SF = NULL; /* Gets the system time format as: "YYYY/MM/DD" */public static String Getcurrentdate () {Date d = new Date (); SF = new SimpleDateFormat ("yyyy mm month DD day"); Return Sf.format (d); }/* Timestamp converted to character channeling */public static String getdatetostring (long time) {Date D = new Date (time); SF = new SimpleDateFormat ("yyyy mm month DD day"); Return Sf.format (d); }/* Convert string to timestamp */public static long Getstringtodate (string time) {SF = new SimpleDateFormat ("yyyy mm DD day"); Date date = new Date (); try{date = Sf.parse (time); } catch (ParseException e) {//TODO auto-generated catch block E.printstacktrace (); } return Date.gettime (); }/** * Get timestamp directly * @return */public static String Gettimestamp (){String currentdate = Getcurrentdate (); SF = new SimpleDateFormat ("yyyy mm month DD day"); Date date = new Date (); try{date = Sf.parse (currentdate); } catch (ParseException e) {e.printstacktrace (); } return String.valueof (Date.gettime ()); } }
Time Stamp Tool class