Java Date to String dateToISODate(Date date)

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

Description

date To ISO Date

License

Open Source License

Declaration

public static String dateToISODate(Date date) 

Method Source Code

//package com.java2s;
/**/*www  .j av a2 s. co  m*/
 * Copyright (c) 2010-2016, openHAB.org and others.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */

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

public class Main {
    public static String dateToISODate(Date date) {
        TimeZone tz = TimeZone.getTimeZone("UTC");
        SimpleDateFormat dateFormat = new SimpleDateFormat(
                "yyyy-MM-dd'T'HH:mm:ss.S'Z'");
        dateFormat.setTimeZone(tz);
        return dateFormat.format(date);
    }
}

Related

  1. dateToHttpDateString(Date d)
  2. dateToHuman(Date date)
  3. DateToInteger(Date date)
  4. dateToIso(Date d)
  5. dateToIso8601String(Date date)
  6. dateToOracleDateString(Date date)
  7. dateToRelativeTime(Date date)
  8. dateToRFC1123(Date date)
  9. dateToRFC3339(Date d)