Java tutorial
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; public class Main { /** * Get formatted date string */ public static String getFormattedDateString(Date date, String format) { Calendar cal = Calendar.getInstance(); TimeZone timeZone = cal.getTimeZone(); SimpleDateFormat dateFormat = new SimpleDateFormat(format); dateFormat.setTimeZone(timeZone); return dateFormat.format(date); } }