Here you can find the source of toUTCString(Date date)
Parameter | Description |
---|---|
date | a parameter |
public static String toUTCString(Date date)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { /**//from ww w.java2 s .co m * Converts a date to a UTC String representation * * @param date * @return the formatted date */ public static String toUTCString(Date date) { SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); sd.setTimeZone(TimeZone.getTimeZone("GMT")); return sd.format(date); } }