Java Date Now getCurrentDateAndTime()

Here you can find the source of getCurrentDateAndTime()

Description

get Current Date And Time

License

Open Source License

Declaration

public static String getCurrentDateAndTime() 

Method Source Code

//package com.java2s;
/*//from w w  w. j a v  a2  s  .  co m
 * Copyright 2007 The JA-SIG Collaborative. All rights reserved. See license
 * distributed with this file and available online at
 * http://www.uportal.org/license.html
 */

import java.text.DateFormat;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static String getCurrentDateAndTime() {
        return getFormattedDateAndTime(new Date());
    }

    public static String getFormattedDateAndTime(final Date date) {
        final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
        // Google Does not set this.
        // dateFormat.setTimeZone(UTC_TIME_ZONE);
        return dateFormat.format(date);
    }
}

Related

  1. getCurrentDate(String pattern, Locale locale)
  2. getCurrentDate2(String format)
  3. getCurrentDate_String()
  4. getCurrentDate_YYYY_MM_DD()
  5. getCurrentDateAllformated()
  6. getCurrentDateAndTimeFormat()
  7. getCurrentDateAsNiceString()
  8. getCurrentDateAsNumericEncodedByteArray()
  9. getCurrentDateAsString()