How to convert Time to Long?

18,949

Use getTime():

Time t = Time.valueOf("2:00:00");
long l = t.getTime();
Share:
18,949
LA_
Author by

LA_

To search in your posts only type: user:me text To list all your unaccepted questions, type: user:me hasaccepted:0 My questions list: link

Updated on July 10, 2022

Comments

  • LA_
    LA_ almost 2 years

    For ex., I have the following value:

    Time.valueOf("2:00:00")
    

    how should I convert it to Long? (to be stored in SQLite database as Real)

    java.sql.Time is used.

  • Andriya
    Andriya almost 5 years
    It shows the wrong long value i mean it returns wrong timestamp value. Time t = Time.valueOf("05:50:00"); l = t.getTime(); but i get l as 1200000 this is not timestamp for that