File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
sqldev/src/main/java/org/utplsql/sqldev/model Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 1515 */
1616package org .utplsql .sqldev .model ;
1717
18+ import java .text .ParseException ;
1819import java .text .SimpleDateFormat ;
1920import java .util .Collections ;
2021import java .util .Date ;
2122import java .util .List ;
2223
24+ import org .utplsql .sqldev .exception .GenericRuntimeException ;
25+
2326public class StringTools {
2427 // do not instantiate this class
2528 private StringTools () {
@@ -87,4 +90,17 @@ public static String getSysdate() {
8790 return millisToDateTimeString (System .currentTimeMillis ());
8891 }
8992
93+ public static long dateTimeStringToMillis (final String dateTime ) {
94+ // handle milliseconds separately since they get lost (rounded) when converted to date
95+ final SimpleDateFormat df = new SimpleDateFormat ("yyyy-MM-dd'T'HH:mm:ss" );
96+ Date date ;
97+ try {
98+ date = df .parse (dateTime .substring (0 , 20 ));
99+ } catch (ParseException e ) {
100+ throw new GenericRuntimeException ("cannot parse datetime string " + dateTime + "." , e );
101+ }
102+ long millis = Long .parseLong (dateTime .substring (20 , 23 ));
103+ return date .getTime () + millis ;
104+ }
105+
90106}
You can’t perform that action at this time.
0 commit comments