0% found this document useful (0 votes)
3 views1 page

Java Date Formatting Examples

The document contains a Java program that demonstrates various date formatting options using the SimpleDateFormat class. It creates a Date object and formats it into different string representations, including formats like 'dd/MM/yyyy' and 'MM-dd-yyyy'. The formatted dates are then printed to the console.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Java Date Formatting Examples

The document contains a Java program that demonstrates various date formatting options using the SimpleDateFormat class. It creates a Date object and formats it into different string representations, including formats like 'dd/MM/yyyy' and 'MM-dd-yyyy'. The formatted dates are then printed to the console.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

File: /home/mitacsc/tyi341/date.

java Page 1 of 1

import [Link];
import [Link];

class date
{
public static void main(String args[])
{
Date date=new Date();
SimpleDateFormat formatter=new SimpleDateFormat("dd/MM/yyyy");
String strDate=[Link](date);
[Link](strDate);

SimpleDateFormat formatter1=new SimpleDateFormat("MM-dd-yyyy");


String strDate1=[Link](date);
[Link](strDate1);

SimpleDateFormat formatter2=new SimpleDateFormat("EEEEE MMMMM dd yyyy");


String strDate2=[Link](date);
[Link](strDate2);

SimpleDateFormat formatter3=new SimpleDateFormat("EEEEE MMMMM dd HH:mm:ss z yyyy");


String strDate3=[Link](date);
[Link](strDate3);

SimpleDateFormat formatter4=new SimpleDateFormat("dd/MM/yyyy HH:mm:ss a");


String strDate4=[Link](date);
[Link](strDate4);
}
}

You might also like