Here you can find the source of toGMT(final long ts)
Parameter | Description |
---|---|
ts | time |
public static String toGMT(final long ts)
//package com.java2s; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { public static final String STANDARD_DATETIMEFORMAT = "dd.MM.yyyy HH:mm"; public static final String TZ_UTC = "UTC"; /**//from www .j av a 2s. c o m * @param ts time * @return Wandelt einen Timestamp in eine String bezogen auf GMT um. * */ public static String toGMT(final long ts) { return toGMT(new Timestamp(ts)); } /** * @param ts time * @return Wandelt einen Timestamp in eine String bezogen auf GMT um. * */ public static String toGMT(final Date ts) { return timestampToString(ts, STANDARD_DATETIMEFORMAT, TZ_UTC); } /** * * @param ts * @param format * @param tzId * @return * * @author Anton Nedbailo * @date Sep 29, 2013 */ public static String timestampToString(final Date ts, final String format, final String tzId) { Date ret = ts; SimpleDateFormat formatter = new SimpleDateFormat(format); formatter.setTimeZone(TimeZone.getTimeZone(tzId)); if (ret == null) { ret = new Date(); } return formatter.format(ret); } }