Java Calendar Second getSecondsSinceMidnight(final Calendar time)

Here you can find the source of getSecondsSinceMidnight(final Calendar time)

Description

get Seconds Since Midnight

License

Open Source License

Return

the number of seconds since midnight, as calculated by the , and fields in the passed .

Declaration

public static int getSecondsSinceMidnight(final Calendar time) 

Method Source Code


//package com.java2s;
// Licensed under the MIT license. See License.txt in the repository root.

import java.util.Calendar;

public class Main {
    /**//from   w ww  .j  av  a2  s .  c o m
     * @return the number of seconds since midnight, as calculated by the
     *         {@link Calendar#HOUR_OF_DAY}, {@link Calendar#MINUTE} and
     *         {@link Calendar#SECOND} fields in the passed {@link Calendar}.
     */
    public static int getSecondsSinceMidnight(final Calendar time) {
        return time.get(Calendar.SECOND) + (time.get(Calendar.MINUTE) * 60)
                + (time.get(Calendar.HOUR_OF_DAY) * 3600);
    }
}

Related

  1. after(final Calendar first, final Calendar second)
  2. clearCalendarSecondWithRear(Calendar cal)
  3. dateEquals(Calendar calendarFirst, Calendar calendarSecond)
  4. getSecond(Calendar calendar)
  5. getSecondsSinceMidnight(Calendar c)
  6. getTimeInSeconds(Calendar t)
  7. getTimeSeconds(Calendar cal)
  8. getTimestampInDayFirstSecond(final Calendar calendar)
  9. hasPassed10Second(Calendar time)