Back to project page Andriod-PC-GPSApplication.
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.
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; } }