Here you can find the source of getGmtTimeString(double startTime)
Parameter | Description |
---|---|
startTime | The long date number. |
public static String getGmtTimeString(double startTime)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { /** String used for non-available data */ private static final String NOT_AVAILABLE = "NA"; /**/*w w w . j a v a2 s .c om*/ * Returns a time string of the form yyyy-MM-dd'T'HH:mm:ss'Z' from the * specified date number. If the input is null, then the value of * NOT_AVAILABLE is returned. The string represents GMT time. * * @param startTime The long date number. * @return * @see #NOT_AVAILABLE */ public static String getGmtTimeString(double startTime) { if (Double.isNaN(startTime)) { return NOT_AVAILABLE; } Date date = new Date(Math.round(startTime)); SimpleDateFormat formatter = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss'Z'"); formatter.setTimeZone(TimeZone.getTimeZone("GMT")); return formatter.format(date); } }