Added the AccurateTimestamp file
This file converts string timestamp to timestamp and the other way , its used for the SimpleRegistry tagsvote-registry
parent
87e8ad9470
commit
36d94b41ab
|
@ -0,0 +1,35 @@
|
||||||
|
package meerkat;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Vladimir Eliezer Tokarev on 1/15/2016.
|
||||||
|
* converts time stamps to strings and the other way
|
||||||
|
*/
|
||||||
|
public abstract class AccurateTimestamp {
|
||||||
|
|
||||||
|
private static final String DATE_FORMAT = "yyyy-MM-dd hh:mm:ss.SSS";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts current timestamp to string
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String GetCurrentTimestampString(){
|
||||||
|
return new SimpleDateFormat(DATE_FORMAT).format(new java.util.Date());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convets string timesta,p tp java.sql.timestamp
|
||||||
|
* @param timestamp string
|
||||||
|
* @return
|
||||||
|
* @throws ParseException
|
||||||
|
*/
|
||||||
|
public static java.sql.Timestamp GetCurrentTimestampFromString(String timestamp) throws ParseException {
|
||||||
|
Date date = new SimpleDateFormat(DATE_FORMAT).parse(timestamp);
|
||||||
|
return new Timestamp(date.getTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue