Java Date Now getCurrentUTCTimeAsString()

Here you can find the source of getCurrentUTCTimeAsString()

Description

get Current UTC Time As String

License

Open Source License

Declaration

public static String getCurrentUTCTimeAsString() 

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 {
    static final String DATEFORMAT = "yyyy-MM-dd";

    public static String getCurrentUTCTimeAsString() {
        final SimpleDateFormat sdf = new SimpleDateFormat(DATEFORMAT);
        sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
        final String utcTime = sdf.format(new Date());

        return utcTime;
    }/*from   w w w  .j a v a 2 s. co m*/

    public static String format(Date date) {
        SimpleDateFormat dateFormat = new SimpleDateFormat(DATEFORMAT);
        return dateFormat.format(date);
    }
}

Related

  1. getCurrentUTCDate()
  2. getCurrentUtcDate()
  3. getCurrentUTCSeconds(Date current)
  4. getCurrentUTCString()
  5. getCurrentUTCTime()
  6. getCurrentWeekDay(Date date, int day)
  7. getCurrentWeekDays()
  8. getCurrentWeekFirst()
  9. getCurrentYear()