Java tutorial
//package com.java2s; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String convertToString(Date source, String format) { if (source == null) return null; DateFormat df = new SimpleDateFormat(format); return df.format(source); } }