Here you can find the source of dateToString(Date date)
public static String dateToString(Date date)
//package com.java2s; /*// www. ja va 2s . c o m Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved See License.txt in the project root for license information. */ import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.TimeZone; public class Main { public static String dateToString(Date date) { if (date == null) { return "NULL"; } SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.'SSS'Z'", Locale.getDefault()); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); String formatted = dateFormat.format(date); return formatted; } }