Here you can find the source of formatISO8601(final Date date)
public static String formatISO8601(final Date date)
//package com.java2s; /*/* w w w . ja v a2s . co m*/ * ==================================================================== * Copyright (c) 2005-2012 sventon project. All rights reserved. * * This software is licensed as described in the file LICENSE, which * you should have received as part of this distribution. The terms * are also available at http://www.sventon.org. * If newer versions of this license are posted there, you may use a * newer version instead, at your option. * ==================================================================== */ import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static final String ISO8601_DATE_FORMAT_PATTERN = "yyyy-MM-dd"; public static String formatISO8601(final Date date) { if (date == null) return ""; SimpleDateFormat dateFormat = new SimpleDateFormat(ISO8601_DATE_FORMAT_PATTERN); return dateFormat.format(date); } }