Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Time variable to milliseconds

Tags:

java

I am having a variable which is called from_time and I am reading the infor from the DB.

Time from_time = rs.getTime("nfrm_time");

How to convert the from_time into milliseconds and seconds?

Thanks for the help

like image 509
maas Avatar asked Apr 23 '26 19:04

maas


2 Answers

java.sql.Time extends java.util.Date, and has getTime() method which returns millis.

like image 80
Bozho Avatar answered Apr 25 '26 09:04

Bozho


You should use the method getTime():

public class Main
{
    public static void main(String[] args)
    {
        Time t = new Time(System.currentTimeMillis());
        long l = t.getTime();
    }
}
like image 20
duduamar Avatar answered Apr 25 '26 07:04

duduamar