Java Calendar Time calendarToGPSTime(Calendar calendar)

Here you can find the source of calendarToGPSTime(Calendar calendar)

Description

Takes a date string of the form dd-mm-yyyy hh:mm:ss and converts it into a GPS time representing the number of seconds since 01-06-1980 00:00:00.

License

Open Source License

Parameter

Parameter Description
date a parameter

Declaration

public static long calendarToGPSTime(Calendar calendar) 

Method Source Code


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

import java.util.Calendar;

public class Main {
    public static final long GPS_UNIX_EPOCH_OFFSET = 328665600;

    /**//from ww  w .  j  a  va2s  .c o m
     * Takes a date string of the form dd-mm-yyyy hh:mm:ss and converts it into a GPS time
     * representing the number of seconds since 01-06-1980 00:00:00.
     * 
     * @param date
     * @return
     */
    public static long calendarToGPSTime(Calendar calendar) {
        // Return the time since 01/06/1980 00:00:00
        return calendar.getTimeInMillis() / 1000L - GPS_UNIX_EPOCH_OFFSET;
    }
}

Related

  1. calendar2TimeStamp(Calendar cal)
  2. calendarFromString(String dateString, String timeString)
  3. ceilTime(Calendar calendar)
  4. clearCalendarTime(Calendar cal)
  5. clearCalendarTimeParts(Calendar cal)
  6. clearTime(Calendar c)