Here you can find the source of formatDateTime(Date date)
public static String formatDateTime(Date date)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { public static final String FORMAT_DATETIME = "yyyy-MM-dd HH:mm:ss"; public static String formatDateTime(Date date) { if (date == null) return null; SimpleDateFormat sdf = new SimpleDateFormat(FORMAT_DATETIME); sdf.setTimeZone(TimeZone.getTimeZone("GMT+8")); return sdf.format(date); }//from w ww.j a va2s.c om public static String formatDateTime(Date date, String style) { if (date == null) return null; SimpleDateFormat sdf = new SimpleDateFormat(style); sdf.setTimeZone(TimeZone.getTimeZone("GMT+8")); return sdf.format(date); } }