Here you can find the source of to_char(Date date, String format)
public static String to_char(Date date, String format)
//package com.java2s; //License from project: Open Source License import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String to_char(Date date, String format) { SimpleDateFormat formatter = new SimpleDateFormat(format); return formatter.format(date).trim(); }/* ww w. j av a 2 s . c o m*/ public static String to_char(Timestamp tsp, String format) { if (tsp == null) { return ""; } return to_char(new Date(tsp.getTime()), format); } }