Here you can find the source of formatDate(Date date)
public static final String formatDate(Date date)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; import com.google.common.base.Preconditions; public class Main { public static final String TIMESTAMP_FORMAT = "yyyy-MM-dd HH:mm:ss z"; public static final String formatDate(Date date) { Preconditions.checkNotNull(date, "date must not be null"); String formattedDate = new SimpleDateFormat(TIMESTAMP_FORMAT).format(date); StringBuffer dateFormatBuilder = new StringBuffer("TO_DATE('"); dateFormatBuilder.append(formattedDate).append("', 'yyyy-MM-dd HH:mm:ss z')"); return dateFormatBuilder.toString(); }//from ww w . ja v a 2 s . c om }