Here you can find the source of formatDate(Date value)
public static String formatDate(Date value)
//package com.java2s; /**/*from w w w .j a v a 2s . com*/ * Logspace * Copyright (c) 2015 Indoqa Software Design und Beratung GmbH. All rights reserved. * This program and the accompanying materials are made available under the terms of * the Eclipse Public License Version 1.0, which accompanies this distribution and * is available at http://www.eclipse.org/legal/epl-v10.html. */ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { private static final String ISO_8601_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; private static final String TIMEZONE_UTC = "UTC"; public static String formatDate(Date value) { String formattedValue; if (value == null) { formattedValue = null; } else { formattedValue = getTimeFormat().format(value); } return formattedValue; } private static DateFormat getTimeFormat() { DateFormat df = new SimpleDateFormat(ISO_8601_DATE_FORMAT); df.setTimeZone(TimeZone.getTimeZone(TIMEZONE_UTC)); return df; } }