Here you can find the source of formatDate(Date date, StringBuffer buffer)
public static final void formatDate(Date date, StringBuffer buffer)
//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); } }