Skip to content

Commit aae16e9

Browse files
PavelAplevichmisaochan
authored andcommitted
Fixed wrong upload dates after image upload
1 parent 528a307 commit aae16e9

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

app/src/main/java/fr/free/nrw/commons/contributions/Contribution.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class Contribution extends Media {
2929
private static final String TEMPLATE_DATE_ACC_TO_EXIF = "{{According to EXIF data|%s}}";
3030

3131
//{{date|2009|1|9}} → 9 January 2009
32-
private static final String TEMPLATE_DATA_OTHER_SOURCE = "{{date|%d|%d|%d}}";
32+
private static final String TEMPLATE_DATA_OTHER_SOURCE = "{{date|%s}}";
3333

3434
public static Creator<Contribution> CREATOR = new Creator<Contribution>() {
3535
@Override
@@ -210,16 +210,11 @@ public String getPageContents(Context applicationContext) {
210210
*/
211211
private String getTemplatizedCreatedDate() {
212212
if (dateCreated != null) {
213+
java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd");
213214
if (UploadableFile.DateTimeWithSource.EXIF_SOURCE.equals(dateCreatedSource)) {
214-
return String.format(Locale.ENGLISH, TEMPLATE_DATE_ACC_TO_EXIF, DateUtil.getDateStringWithSkeletonPattern(dateCreated, "yyyy-MM-dd")) + "\n";
215+
return String.format(Locale.ENGLISH, TEMPLATE_DATE_ACC_TO_EXIF, dateFormat.format(dateCreated)) + "\n";
215216
} else {
216-
Calendar calendar = Calendar.getInstance();
217-
calendar.setTime(dateCreated);
218-
calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
219-
return String.format(Locale.ENGLISH, TEMPLATE_DATA_OTHER_SOURCE,
220-
calendar.get(Calendar.YEAR),
221-
calendar.get(Calendar.MONTH),
222-
calendar.get(Calendar.DAY_OF_MONTH)) + "\n";
217+
return String.format(Locale.ENGLISH, TEMPLATE_DATA_OTHER_SOURCE, dateFormat.format(dateCreated)) + "\n";
223218
}
224219
}
225220
return "";

0 commit comments

Comments
 (0)