//Program to use date format …………………
package Time;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateTimeExample
{
public static void main(String[] args)
{
Date date = new Date();
System.out.println("Date is (with out using any date formate ==================> "+date);
SimpleDateFormat simpleDateFormate = new SimpleDateFormat("E dd.MM.yyyy 'at' hh:mm:ssa zzz");
System.out.println("SimpleDateFormat1 is (\"E dd.MM.yyyy 'at' hh:mm:ssa zzz\")===> "+simpleDateFormate.format(date));
simpleDateFormate = new SimpleDateFormat("E d.MM.y 'at' hh:mm:ssa zzz");
System.out.println("SimpleDateFormat2 is (\"E d.MM.y 'at' hh:mm:ssa zzz\") ======> "+simpleDateFormate.format(date));
simpleDateFormate = new SimpleDateFormat("EEEE dd.MMMM.yyyy 'at' hh:mm:ssa");
System.out.println("SimpleDateFormat3 is (\"EEEE dd.MMMM.yyyy 'at' hh:mm:ssa\") => "+simpleDateFormate.format(date));
}
}
OUTPUT =>
Date is (with out using any date formate ==================> Tue Jan 10 13:13:10 IST 2012
SimpleDateFormat1 is ("E dd.MM.yyyy 'at' hh:mm:ssa zzz")===> Tue 10.01.2012 at 01:13:10PM IST
SimpleDateFormat2 is ("E d.MM.y 'at' hh:mm:ssa zzz") ======> Tue 10.01.12 at 01:13:10PM IST
SimpleDateFormat3 is ("EEEE dd.MMMM.yyyy 'at' hh:mm:ssa") => Tuesday 10.January.2012 at 01:13:10PM
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateTimeExample
{
public static void main(String[] args)
{
Date date = new Date();
System.out.println("Date is (with out using any date formate ==================> "+date);
SimpleDateFormat simpleDateFormate = new SimpleDateFormat("E dd.MM.yyyy 'at' hh:mm:ssa zzz");
System.out.println("SimpleDateFormat1 is (\"E dd.MM.yyyy 'at' hh:mm:ssa zzz\")===> "+simpleDateFormate.format(date));
simpleDateFormate = new SimpleDateFormat("E d.MM.y 'at' hh:mm:ssa zzz");
System.out.println("SimpleDateFormat2 is (\"E d.MM.y 'at' hh:mm:ssa zzz\") ======> "+simpleDateFormate.format(date));
simpleDateFormate = new SimpleDateFormat("EEEE dd.MMMM.yyyy 'at' hh:mm:ssa");
System.out.println("SimpleDateFormat3 is (\"EEEE dd.MMMM.yyyy 'at' hh:mm:ssa\") => "+simpleDateFormate.format(date));
}
}
OUTPUT =>
Date is (with out using any date formate ==================> Tue Jan 10 13:13:10 IST 2012
SimpleDateFormat1 is ("E dd.MM.yyyy 'at' hh:mm:ssa zzz")===> Tue 10.01.2012 at 01:13:10PM IST
SimpleDateFormat2 is ("E d.MM.y 'at' hh:mm:ssa zzz") ======> Tue 10.01.12 at 01:13:10PM IST
SimpleDateFormat3 is ("EEEE dd.MMMM.yyyy 'at' hh:mm:ssa") => Tuesday 10.January.2012 at 01:13:10PM
No comments:
Post a Comment