Android Open Source - Andriod-PC-GPSApplication Date Time Util






From Project

Back to project page Andriod-PC-GPSApplication.

License

The source code is released under:

MIT License

If you think the Android project Andriod-PC-GPSApplication listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.dev.appxpress.gps.android_pc.util;
/*www .j  av a  2 s  .co m*/
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;

/**
 * @author NThusitha
 *
 */
public class DateTimeUtil {

  /**
   * @return - UTC Date/time
   */
  public static String nowUTCString(){
    
    Calendar calendar = Calendar.getInstance();
    TimeZone timeZone = calendar.getTimeZone();
    
    long currentTime = System.currentTimeMillis();
    int offsetWithUTC = timeZone.getOffset(currentTime);
    long utcTime = currentTime - offsetWithUTC;
    Date now = new Date(utcTime);
    SimpleDateFormat df = new SimpleDateFormat();
    return df.format(now);
    
  }
  
  /**
   * @return - Long version of time.
   */
  public static long nowUTC(){
    
    Calendar calendar = Calendar.getInstance();
    TimeZone timeZone = calendar.getTimeZone();
    
    long currentTime = System.currentTimeMillis();
    int offsetWithUTC = timeZone.getOffset(currentTime);
    long utcTime = currentTime - offsetWithUTC;
    
    return utcTime;
    
  }
  
}




Java Source Code List

com.dev.appxpress.gps.android_pc.AndroidDataReader.java
com.dev.appxpress.gps.android_pc.AndroidPCClientLauncher.java
com.dev.appxpress.gps.android_pc.data.handler.GPSDataHandler.java
com.dev.appxpress.gps.android_pc.domain.GPSAware.java
com.dev.appxpress.gps.android_pc.domain.GPSWayPoint.java
com.dev.appxpress.gps.android_pc.runtime.exec.PortForwarder.java
com.dev.appxpress.gps.android_pc.util.DateTimeUtil.java
com.dev.appxpress.gps.android_pc.util.PrintManager.java
com.example.appxgpsmodule.Globals.java
com.example.appxgpsmodule.Loaded.java
com.example.appxgpsmodule.Start.java
com.example.appxgpsmodule.storage.ExternalStorageReader.java