Java Date to Second getSecond(Date date)

Here you can find the source of getSecond(Date date)

Description

Return second from a Date .

License

Open Source License

Parameter

Parameter Description
date a parameter

Declaration

public static int getSecond(Date date) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

public class Main {
    public static final Locale LOCALE_DEFAULT = Locale.getDefault();

    public static int getSecond(Date date) {
        return getCalendar(date).get(Calendar.SECOND);
    }/*from   w  ww  .j a  va 2 s .com*/

    public static Calendar getCalendar() {
        return Calendar.getInstance();
    }

    public static Calendar getCalendar(Date datetime) {
        return getCalendar(datetime, LOCALE_DEFAULT);
    }

    public static Calendar getCalendar(Date datetime, Locale locale) {
        Calendar cal = Calendar.getInstance(locale);
        cal.setTime(datetime);
        return cal;
    }
}

Related

  1. getSecond(Date d)
  2. getSecond(Date date)
  3. getSecond(Date date)
  4. getSecond(java.util.Date date)
  5. getSecondOfDate(Date date)
  6. getSecondOfMinute(final Date date)
  7. getSeconds(Date d)