java大小寫字母轉(zhuǎn)換 java檢查字符串是否是合法的日期?
java檢查字符串是否是合法的日期?Public static Boolean isvaliddate(string STR){Boolean convertsucces=true//將日期格式指定為
java檢查字符串是否是合法的日期?
Public static Boolean isvaliddate(string STR){Boolean convertsucces=true//將日期格式指定為四位年份/兩位月份/兩位日期。請注意,yyyy/mm/DD區(qū)分大小寫;simpledateformat format=new simpledateformat(“yyyy/mm/DD HH:mm”)請嘗試{//set lenient to false否則,simpledateformat將更寬松地驗證日期。例如,2007/02/29將被接受并轉(zhuǎn)換為2007/03/01格式.setLenient(錯誤)格式.parse(STR)}catch(parseexception E){//E.printstacktrace()//如果拋出java.text.ParseException異?;騈ullPointerException,表示格式錯誤convertsucces=false}return convertsucces}