boncey / Flickr4Java

Java API For Flickr. Fork of FlickrJ
BSD 2-Clause "Simplified" License
174 stars 155 forks source link

TODO sentence from line 363 in Photo.java #720

Open quagmir3 opened 5 months ago

quagmir3 commented 5 months ago

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

erro_fechhas erro_fechhas_resultado_1

Actual behaviour

erro_fechhas_resultado_2

Log

Please copy paste the log here if available