Skip to content

TODO sentence from line 363 in Photo.java #720

@quagmir3

Description

@quagmir3

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

  • 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

erro_fechhas
erro_fechhas_resultado_1

Actual behaviour

erro_fechhas_resultado_2

Log

Please copy paste the log here if available

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions