Menu
Question Index
...

What will be output of the following program?

import java.util.*;
public class FormattingDateAndTime {
    public static void main(String[] args) {
        Calendar cal = Calendar.getInstance();
        Formatter fmt = new Formatter();
        cal.set(Calendar.HOUR, 02);
        cal.set(Calendar.MINUTE, 55);
        cal.set(Calendar.SECOND, 15);
        fmt.format("%tr", cal);
        System.out.println(fmt);
    }
}


02:55:15 PM
02:55:15 AM
14:55:15
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Formatting Date And Time In Java With Example

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App