-
How to convert Date object to String?
-
- SimpleDateFormat simple = new SimpleDateFormat(“yyyy-mm-dd”);
simple.format(new Date()); - SimpleDateFormat simple = new SimpleDateFormat(“yyyy-mm-dd”);
simple.parse(new Date()); - SimpleDateFormat simple = new SimpleDateFormat(“yyyy-mm-dd”);
new Date().parse(); - SimpleDateFormat simple = new SimpleDateFormat(“yyyy-mm-dd”);
new Date().format(); - None of these
- SimpleDateFormat simple = new SimpleDateFormat(“yyyy-mm-dd”);
Correct Option: A
SimpleDateFormat takes a string containing pattern. sdf.format converts the Date object to String.