Home » JAVA Programming » Basic Datatypes » Question
  1. How to convert Date object to String?
    1. SimpleDateFormat simple = new SimpleDateFormat(“yyyy-mm-dd”);
      simple.format(new Date());
    2. SimpleDateFormat simple = new SimpleDateFormat(“yyyy-mm-dd”);
      simple.parse(new Date());
    3. SimpleDateFormat simple = new SimpleDateFormat(“yyyy-mm-dd”);
      new Date().parse();
    4. SimpleDateFormat simple = new SimpleDateFormat(“yyyy-mm-dd”);
      new Date().format();
    5. None of these
Correct Option: A

SimpleDateFormat takes a string containing pattern. sdf.format converts the Date object to String.



Your comments will be displayed only after manual approval.