Menu
Question Index
...


Write a program to print date and time in various formats according to given date object.

Input (Date) Printed Output
2011-Apr-02 19:35:45 02-Apr-2011 07:35 PM
11-4-02 19_35
20110402193545
1947-Aug-15 00:00:00 15-Aug-1947 12:00 AM
47-8-15 00_00
19470815000000
2012-Nov-19 17:18:19 19-Nov-2012 05:18 PM
12-11-19 17_18
20121119171819
2013-Jan-26 8:00:00 26-Jan-2013 08:00 AM
13-1-26 08_00
20130126080000
2012-Feb-02 15:15:15 02-Feb-2012 03:15 PM
12-2-02 15_15
20120202151515

class DateAndTimeInVariousFormats

{    public static void main(String s[])
    {
        Calendar calendar = new GregorianCalendar();
        calendar.set(2011, 3, 2, 19, 35, 45);
        printDateAndTimeInVariousFormats(calendar.getTime());

    }


public static void printDateAndTimeInVariousFormats(Date date) {
//Write code here to print the date and time in various formats according to given date object.
}
}

Doubts

Problems

Topic: Locale Class In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App