Java UTC Date nowUtc(String pattern)

Here you can find the source of nowUtc(String pattern)

Description

Returns the current system date as string with the specified format

License

Apache License

Declaration

public static String nowUtc(String pattern) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

public class Main {
    /**/*from  ww w  .jav  a  2  s. c om*/
     * Returns the current system date as string with the specified format
     */
    public static String nowUtc(String pattern) {
        final SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
        dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
        return dateFormat.format(now());
    }

    /**
     * Returns the current system date
     */
    public static Date now() {
        return new Date();
    }

    /**
     * Returns the current system date as string with the specified format
     */
    public static String now(String pattern) {
        return new SimpleDateFormat(pattern).format(now());
    }
}

Related

  1. getUtcTimestamp()
  2. getUTCTimestamp(Date date)
  3. getUtcTimestampAsString(Date date)
  4. getUTCTimeString4Digits(Date date)
  5. nowInUTC()
  6. nowUTCString()
  7. SerializeUtc(Date dt)
  8. stringToUTC(String utc)
  9. toUTCDate(String dateStr)