Here you can find the source of toString(Date value, String format)
public static String toString(Date value, String format)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { public static String toString(Date value, String format) { if (value != null) { SimpleDateFormat dateFormat = new SimpleDateFormat(format); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); return dateFormat.format(value); } else {//from w ww .j a v a 2s .c o m return ""; } } }