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 15
15
*/
16
16
package org .utplsql .sqldev .model ;
17
17
18
+ import java .text .ParseException ;
18
19
import java .text .SimpleDateFormat ;
19
20
import java .util .Collections ;
20
21
import java .util .Date ;
21
22
import java .util .List ;
22
23
24
+ import org .utplsql .sqldev .exception .GenericRuntimeException ;
25
+
23
26
public class StringTools {
24
27
// do not instantiate this class
25
28
private StringTools () {
@@ -87,4 +90,17 @@ public static String getSysdate() {
87
90
return millisToDateTimeString (System .currentTimeMillis ());
88
91
}
89
92
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
+
90
106
}
You can’t perform that action at this time.
0 commit comments