Results 1 to 1 of 1
- 10-04-2007, 09:28 PM #1
How to format the date in particular pattern
This tip will show the use of SimpleDateFormat class. This class format the date in to the desired pattern. This sample program format the current system date to the format "dd/MM/yyyy".
Java Code:import java.text.SimpleDateFormat; import java.util.Date; public class FormatterExp { public static void main(String[] args) { // pattern to be used in formatting the date String pattern = "dd/MM/yyyy"; SimpleDateFormat sdf = new SimpleDateFormat(); // apply the pattern to the SimpleDateFormat class sdf.applyPattern(pattern); // Format and print the date in the desired format. System.out.println("Formatted date :- " + sdf.format(new Date())); } }
Similar Threads
-
Difference between current date and anothe date
By vijay balusamy in forum New To JavaReplies: 1Last Post: 04-16-2008, 04:15 PM -
How to format the date in particular pattern
By Java Tip in forum java.textReplies: 0Last Post: 04-04-2008, 02:35 PM -
Timestamp in SQL format
By Java Tip in forum Java TipReplies: 0Last Post: 02-10-2008, 11:37 AM -
Date format display in CSV file after exporting
By latha in forum Advanced JavaReplies: 0Last Post: 08-03-2007, 08:09 AM -
problems with Date format
By tommy in forum New To JavaReplies: 1Last Post: 07-25-2007, 08:38 PM
Bookmarks