Java UTC Date toUTCString(Date date)

Here you can find the source of toUTCString(Date date)

Description

Converts a date to a UTC String representation

License

Open Source License

Parameter

Parameter Description
date a parameter

Return

the formatted date

Declaration

public static String toUTCString(Date date) 

Method Source Code

//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);
    }
}

Related

  1. nowUtc(String pattern)
  2. nowUTCString()
  3. SerializeUtc(Date dt)
  4. stringToUTC(String utc)
  5. toUTCDate(String dateStr)
  6. toUTCString(long t)
  7. utcTime(Locale locale)
  8. utcTimestamp(Date date)
  9. utcTimeToString(String dateStr)