1 /** 2 *字符串转换Date方法3 * @param dateStr 4 * @param format,例如yyyy-MM-dd HH:mm:ss等5 * @ return6* @ throws exceppeps 8 publicstaticdatestringtodate (字符串数据,字符串格式) throwsexception(9if ) datestr==null||'.equals ) datestr ); 11 ) 12日期=空值; 13 try { 14 } simpledateformatsdf=newsimpledateformat { 14 }; 15date=SDF.parse(datestr ); 16 ) catch(exceptione ) {17 e.printStackTrace ); 18 ) 1920返回日期; 21 ) 22/**23*date字符串转换方法24 * @param date25 * @param format,如yyyy-MM-dd HH:mm:ss等26*@return27* @ throwsexceptiong 29 publicstaticstringdatetostring (date,String format ) throws exception (30if ) date==null ) 31 throw new ); 32 ) 33字符串数据=' '; 34 try { 35 simpledateformatsdf=newsimpledateformat (格式; 36datestr=SDF.format(date; 37 ) catch(exceptione ) {38 e.printStackTrace ); 39 ) 4041返回数据; 42 }
转载于:https://www.cn blogs.com/Jin Zhiming/p/4797470.html