Given this code segment:
DateTimeFormatter fromDateFormat = DateTimeFormatter.ofPattern("MM/dd/yyyy"); // PARSE_DATE DateTimeFormatter toDateFormat = DateTimeFormatter.ofPattern("dd/MMM/YY"); System.out.println(firstOct2015.format(toDateFormat));
Which one of the following statements when replaced with the comment PARSE_DATE will result in the code to print "10/Jan/15"?.
a) DateTimeFormatter firstOct2015 = DateTimeFormatter. parse("01/10/2015", fromDateFormat); b) LocalTime firstOct2015 = LocalTime.parse("01/10/2015", fromDateFormat);/* ww w. j av a 2s .c om*/ c) Period firstOct2015 = Period.parse("01/10/2015", fromDateFormat); d) LocalDate firstOct2015 = LocalDate.parse("01/10/2015", fromDateFormat);
d)
You need to use LocalDate for parsing the date string given in the DateTimeFormatter variable fromDateFormat
(with the format string MM/dd/yyyy").
other options will not compile.