Convert time in 24 hours to seconds

3931 views java
7

I have time in 24 hours using SimpleDateFormat using this code

import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
  public static void main(String[] argv) throws Exception {

    Date date = new Date();
    SimpleDateFormat simpDate;

    simpDate = new SimpleDateFormat("kk:mm:ss");
    System.out.println(simpDate.format(date));

  }
}

I want to know how i would convert time in 24 hours to seconds. I want to be able to tell the next minute by just adding 60 seconds to the time stamp.

How can i convert the 24 hours time to seconds.

answered question

1 Answer

7

Date.getTime() will give you milliseconds. You should be able to convert from there.

posted this

Have an answer?

JD

Please login first before posting an answer.