Java tutorial
/* * Output: 11:27:37 28 Apr 2006 11:27:37 PDT Fri Apr 28 2006 */ import java.text.SimpleDateFormat; import java.util.Date; public class MainClass { public static void main(String args[]) { Date date = new Date(); SimpleDateFormat sdf; sdf = new SimpleDateFormat("hh:mm:ss"); System.out.println(sdf.format(date)); sdf = new SimpleDateFormat("dd MMM yyyy hh:mm:ss zzz"); System.out.println(sdf.format(date)); sdf = new SimpleDateFormat("E MMM dd yyyy"); System.out.println(sdf.format(date)); } }