java - timestamp string split to get date and time effective way -
1) Regular expressions, using pattern
2) Using string split function in class < / P>
I tried to use the split function, I think it is not a good coding practice using splitted such '_' iterative array input string
strings
START_READING_20140723_093539.jpg Description_20140723_093539.jpg Qunantity_20140723_183539.jpg END_READING_20140723_093539 JPG
is the input format: yyyyMMdd_HHmmss
The output format is: 23-07-2014 06:35:39
?
Why not import joda.time.format * for the whole thing. Import joda.time *; DateTimeFormatter inputFormat = DateTimeFormat.forPattern ("YYYYMMDD '_' HHmmss'); Local Datetime Timestamp = Input Format. Parcelocalditis (the string); DateTimeFormatter outputFormat = DateTimeFormat.forPattern ("dd '-' mm '-' yyyy '' hh ':' mm ':' Sarva Shiksha Abhiyan '); String output = output format.print (timestamp);
If you are using Java 8, you should use the Java Time Package instead.
Comments
Post a Comment