You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We found that at line 363 in Photo.java, we were expected to write code that handled the ParseException. So, we wrote code that could do that.
Our code throws a ParseException and displays a message that contains the date with an incorrect format and where that error is located. The latter is achieved with the method getErrorOffset().
Your environment
version of Flickr4Java = 3.0.8
version of JDK = JDK 17
Steps to reproduce
public void setDateTaken(String dateTaken) throws ParseException {
if (dateTaken == null || "".equals(dateTaken)) {
return;
}
try {
DateFormat dateFormat = DATE_FORMATS.get();
Date parsedDate = dateFormat.parse(dateTaken);
if (!dateFormat.format(parsedDate).equals(dateTaken)) {
System.out.println("The date is not valid: " + dateTaken);
} else {
setDateTaken(parsedDate);
}
} catch (ParseException e) {
throw new ParseException("Failed to parse date: " + dateTaken, e.getErrorOffset());
}
}
This code is the one written at the setDateTaken2() method. You can look at the screenshots and compare the output between the previous code and the actual code we are proposing.
Expected behaviour
Actual behaviour
Log
Please copy paste the log here if available
The text was updated successfully, but these errors were encountered:
Subject of the issue
We found that at line 363 in Photo.java, we were expected to write code that handled the ParseException. So, we wrote code that could do that.
Our code throws a ParseException and displays a message that contains the date with an incorrect format and where that error is located. The latter is achieved with the method getErrorOffset().
Your environment
Steps to reproduce
public void setDateTaken(String dateTaken) throws ParseException {
if (dateTaken == null || "".equals(dateTaken)) {
return;
}
try {
DateFormat dateFormat = DATE_FORMATS.get();
Date parsedDate = dateFormat.parse(dateTaken);
if (!dateFormat.format(parsedDate).equals(dateTaken)) {
System.out.println("The date is not valid: " + dateTaken);
} else {
setDateTaken(parsedDate);
}
} catch (ParseException e) {
throw new ParseException("Failed to parse date: " + dateTaken, e.getErrorOffset());
}
}
This code is the one written at the setDateTaken2() method. You can look at the screenshots and compare the output between the previous code and the actual code we are proposing.
Expected behaviour
Actual behaviour
Log
The text was updated successfully, but these errors were encountered: