Java Hour Format formatDate(Date date, StringBuffer buffer)

Here you can find the source of formatDate(Date date, StringBuffer buffer)

Description

format Date

License

Open Source License

Declaration

public static final void formatDate(Date date, StringBuffer buffer) 

Method Source Code


//package com.java2s;
/*//from ww  w  .  j a  v a  2s. c  o m
 * ====================================================================
 * Copyright (c) 2004 TMate Software Ltd.  All rights reserved.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at http://tmate.org/svn/license.html.
 * If newer versions of this license are posted there, you may use a
 * newer version instead, at your option.
 * ====================================================================
 */

import java.text.DateFormat;
import java.text.FieldPosition;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    private static final DateFormat ISO8601_FORMAT_OUT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'000Z'");

    public static final void formatDate(Date date, StringBuffer buffer) {
        ISO8601_FORMAT_OUT.format(date, buffer, new FieldPosition(0));
    }

    public static final String formatDate(Date date) {
        if (date == null || date.getTime() == 0) {
            return null;
        }
        return ISO8601_FORMAT_OUT.format(date);
    }
}

Related

  1. formatDate(Date date, String format, Locale locale)
  2. formatDate(Date date, String patter)
  3. formatDate(Date date, String pattern)
  4. formatDate(Date date, String pattern)
  5. formatDate(Date date, String timeFormat, String timeZone)
  6. formatDate(Date date, TimeZone tz)
  7. formatDate(Date dateString)
  8. formatDate(Date src, String formatPattern)
  9. formatDate(final Date date, final String pattern)