SimpleDateFormat is used for formatting date and time in Java.  This tutorial explains you about how to use Java.util.Date API.

You can select user-defined pattern for date-time formatting.

package com.tutorial.javagenious;
import java.util.*;
import java.text.*;

public class FormatDateTimeTutorial {
   public static void main(String args[]) {

      Date date = new Date( );
      SimpleDateFormat formatedDate = 
      new SimpleDateFormat ("E yyyy.MM.dd 'and Time :' hh:mm:ss a zzz");

      System.out.println("Current Date: " + formatedDate.format(date));
   }
}

 

Current Date: Mon 2013.10.28 & Time is: 02:18:45 PM EST

Enter your email address:

Delivered by FeedBurner



Sandeep Joshi
Mathematics, Technology and Programming are my passion. I am a part of Java Ecosystem and through this blog, I contribute to it. I am here to blog about my interests, views and experiences.
I am on Google+ and Facebook.
I feel proud to be listed as a "National Memory Record Holder" in the Limca Book of Records, 2009 and have attempted for an International Memory record in the Guiness Book of Records. I can remember the value of PI upto 10,000 digits after the decimal (3.1415.....). You can contact me on javagenious.com(At)gmal.com ; I would like to hear from you :)