Here you can find the source of toDateTimeString(Date value)
public static String toDateTimeString(Date value)
//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 toDateTimeString(Date value) { if (value != null) { SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); return dateFormat.format(value); } else {//from ww w. j a v a 2 s. c o m return ""; } } }