Fixed wrong upload dates after image upload
This commit is contained in:
PavelAplevich 2019-09-29 12:28:49 +03:00 committed by Josephine Lim
parent 93b948d205
commit 8d92e08149

View file

@ -29,7 +29,7 @@ public class Contribution extends Media {
private static final String TEMPLATE_DATE_ACC_TO_EXIF = "{{According to EXIF data|%s}}"; private static final String TEMPLATE_DATE_ACC_TO_EXIF = "{{According to EXIF data|%s}}";
//{{date|2009|1|9}} 9 January 2009 //{{date|2009|1|9}} 9 January 2009
private static final String TEMPLATE_DATA_OTHER_SOURCE = "{{date|%d|%d|%d}}"; private static final String TEMPLATE_DATA_OTHER_SOURCE = "{{date|%s}}";
public static Creator<Contribution> CREATOR = new Creator<Contribution>() { public static Creator<Contribution> CREATOR = new Creator<Contribution>() {
@Override @Override
@ -201,16 +201,11 @@ public class Contribution extends Media {
*/ */
private String getTemplatizedCreatedDate() { private String getTemplatizedCreatedDate() {
if (dateCreated != null) { if (dateCreated != null) {
java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd");
if (UploadableFile.DateTimeWithSource.EXIF_SOURCE.equals(dateCreatedSource)) { if (UploadableFile.DateTimeWithSource.EXIF_SOURCE.equals(dateCreatedSource)) {
return String.format(Locale.ENGLISH, TEMPLATE_DATE_ACC_TO_EXIF, DateUtil.getDateStringWithSkeletonPattern(dateCreated, "yyyy-MM-dd")) + "\n"; return String.format(Locale.ENGLISH, TEMPLATE_DATE_ACC_TO_EXIF, dateFormat.format(dateCreated)) + "\n";
} else { } else {
Calendar calendar = Calendar.getInstance(); return String.format(Locale.ENGLISH, TEMPLATE_DATA_OTHER_SOURCE, dateFormat.format(dateCreated)) + "\n";
calendar.setTime(dateCreated);
calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
return String.format(Locale.ENGLISH, TEMPLATE_DATA_OTHER_SOURCE,
calendar.get(Calendar.YEAR),
calendar.get(Calendar.MONTH),
calendar.get(Calendar.DAY_OF_MONTH)) + "\n";
} }
} }
return ""; return "";