Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get a formatted date as milliseconds?

I have a formatted date from sqllite database, to use this in a graph view I need to format it in a long number.

The format is:

2012-07-11 10:55:21

how can I convert it to milliseconds?

like image 360
Reyjohn Avatar asked Jul 11 '12 16:07

Reyjohn


1 Answers

You can convert the string into a Date object using this code:-

Date d = DateFormat.parse(String s)

And then convert it into milliseconds by using the inbuilt method

long millisec = d.getTime();

like image 73
gkris Avatar answered Oct 01 '22 07:10

gkris