Data Tool class (conversion), data tool class conversion
Public static String DateToString (Date tempDate) {String date_str = ""; SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd HH: mm: ss "); // specified date format: try {date_str = formatter. format (tempDate);} catch (Exception ex) {date_str = "";} return date_str;}/*** converts String to Date, format: yyyy-MM-dd HH: mm: ss */public static Date StringToDate (String dateStr) {SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd HH: mm: ss "); // specified Date format long long_temp = 0; Date tempDate; try {long_temp = formatter. parse (dateStr ). getTime (); // first convert to long type tempDate = new Date (long_temp); // convert to Date type} catch (Exception ex) {tempDate = null ;} return tempDate ;}
Annotations are basically not difficult, and will be used in projects.