android - Sqlite Timestamp (String) to epoch? -
i'm trying timestamp (string - yyyy-mm-dd hh:mm:ss
) column converted millis (unix/epoch) simple comparison against system.currenttimemillis()
- there million tutorials converting epoch time human readable format - not going other way.
worst case, i'll write conversion sqlite, prefer use java.
thanks!
you can use simpledateformat
:
string sample = "2014-06-27 11:22:33"; simpledateformat sdf = new simpledateformat( "yyyy-mm-dd hh:mm:ss", locale.us ); parseposition pp = new parseposition( 0 ); date dt = sdf.parse( sample, pp ); if( dt != null ) log.i( "parsed: ", string.valueof( dt.gettime() ) );
Comments
Post a Comment