- Some considerations for recursive use:
Some considerations for recursive use:
When querying the database, prompt ORA-01830: date format picture ends the solution before converting the entire input string
Parameter 1 is the source string, and parameter 2 is the date form to convert to. But to_date limits the accuracy of both, such as To_date (' 2004-05-07 13:23:44 ', ' yyyy-mm-dd ') which cannot be converted.
Recursive method to have the object to receive, no person will have unpredictable problems.
//2017-04-03 2017/04/03 Public StaticString formatString (String dt)throwsparseexception{String back=NULL; if(NULL! = DT && Dt.contains ("/") ) {DateFormat df=NewSimpleDateFormat ("Yyyy/mm/dd"); if(Stringutils.isnotblank (dt)) { back=Df.format (df.parse (DT)); } }Else{ Back= Dt.replace ("-", "/"); back= FormatString (back);//There 's no back here before, and sometimes it's a few seconds. }//log.info ("converted date" +back); returnBack ;} Public Static voidMain (string[] args)throwsparseexception {String str= FormatString ("2017-12-16-16:32:36"); System.out.println (str); }
Common Java Exception issues