Reputation: 1223
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
Upvotes: 3
Views: 1678
Reputation: 3769
Once you have the millis as indicated by Bozho, you can use java.util.concurrent.TimeUnit to rather easily convert to seconds (and hours, days, etc).
Even though it's actually in the concurrent package, I found this to be of great use for general cases.
Upvotes: 1
Reputation: 3924
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();
}
}
Upvotes: 2
Reputation: 597036
java.sql.Time
extends java.util.Date
, and has getTime()
method which returns millis.
Upvotes: 5