Here you can find the source of toGMTString(Date d)
Parameter | Description |
---|---|
d | the date. |
public static String toGMTString(Date d)
//package com.java2s; /* // w ww. j ava 2 s .c o m * Copyright(c) 2005 Center for E-Commerce Infrastructure Development, The * University of Hong Kong (HKU). All Rights Reserved. * * This software is licensed under the GNU GENERAL PUBLIC LICENSE Version 2.0 [1] * * [1] http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */ import java.text.SimpleDateFormat; import java.util.*; public class Main { /** * Returns a string representation of the given Date object of the form: * d MMM yyyy hh:mm:ss GMT * * @param d the date. * @return the GMT string representation of the given date. */ public static String toGMTString(Date d) { SimpleDateFormat formatter = new SimpleDateFormat("d MMM yyyy HH:mm:ss z", Locale.US); formatter.setTimeZone(TimeZone.getTimeZone("GMT")); return formatter.format(d); } }