Home » JAVA Programming » Date & Time » Question
  1. What is the output of this program?
    import java.text.*;
    import java.util.*;
    public class DateFormatting_Example
    {
    public static void main(String args[])
    {
    Date d = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("hh:mm");
    System.out.print(sdf.format(d));
    }
    }
    1. 08:28:25
    2. 08
    3. Compilation Error
    4. 08:28
    5. Runtime Error
Correct Option: D

The code “sdf = new SimpleDateFormat(“hh:mm”);” create a SimpleDataFormat class with format hh:mm where h is hours, m is month.



Your comments will be displayed only after manual approval.