Convert time in 24 hours to seconds

3931 views java

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");


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


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

posted this

Have an answer?


Please login first before posting an answer.