Date Formatting using SimpleDateFormat in Java

In this article, you will see how to format date using SimpleDateFormat in Java

package com.kruders.core;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DateFormatting {
	public static void main( String[] args ) {
		Date date = new Date( );
		SimpleDateFormat sf= new SimpleDateFormat("MM/dd/yyyy hh:mm:ss");
		System.out.println("Current Date: " + sf.format(date));

When you run the above example you’ll get an output like:

Current Date: 11/22/2012 10:29:28

No comments yet.

Leave a Reply