Java Date Format ISO makeDateISO8601(Date date)

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

Description

make Date ISO

License

Apache License

Declaration

public static String makeDateISO8601(Date date) 

Method Source Code

//package com.java2s;
/**//w  w w.  j  av a2  s . c o  m
 * $Id$
 * $URL$
 * DateUtils.java - genericdao - Sep 16, 2008 11:03:28 PM - azeckoski
 **************************************************************************
 * Copyright (c) 2008 Aaron Zeckoski
 * Licensed under the Apache License, Version 2.0
 * 
 * A copy of the Apache License has been included in this 
 * distribution and is available at: http://www.apache.org/licenses/LICENSE-2.0.txt
 *
 * Aaron Zeckoski (azeckoski @ gmail.com) (aaronz @ vt.edu) (aaron @ caret.cam.ac.uk)
 */

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

public class Main {
    public static String makeDateISO8601(Date date) {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
        String result = df.format(date);
        // convert YYYYMMDDTHH:mm:ss+HH00 into YYYYMMDDTHH:mm:ss+HH:00
        result = result.substring(0, result.length() - 2) + ":" + result.substring(result.length() - 2);
        return result;
    }
}

Related

  1. isoDateFormat(final Date date)
  2. isoDateTimeUTC(final Date val)
  3. isoFormat(Date date)
  4. isoTime(Date d)
  5. longToISODate(long longDate)
  6. millisecondsToISO8601(long date)
  7. NowFormatISO()
  8. nowISO8601()
  9. parseISODateFormat(String dateStr)