Java Date to Second getSecondOfDate(Date date)

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

Description

get Second Of Date

License

Open Source License

Declaration

public final static int getSecondOfDate(Date date) 

Method Source Code

//package com.java2s;

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

public class Main {

    public final static int getSecondOfDate(Date date) {
        return getFieldValueByDate(date, Calendar.SECOND);
    }/*  w ww  .ja  va  2s.c  o  m*/

    /**
     * get field value by date and the field, like get the year of a date
     *
     * @param date
     * @param field
     * @return
     */
    public final static int getFieldValueByDate(Date date, int field) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        return c.get(field);
    }
}

Related

  1. getSecond(Date d)
  2. getSecond(Date date)
  3. getSecond(Date date)
  4. getSecond(Date date)
  5. getSecond(java.util.Date date)
  6. getSecondOfMinute(final Date date)
  7. getSeconds(Date d)
  8. getSeconds(Date dt)
  9. getSecondsFromDate(Date date)