Skip to content

Commit 844e090

Browse files
PavelAplevichashishkumar468
authored andcommitted
Fixed wrong upload dates after image upload
1 parent fbbaffb commit 844e090

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

+4-9
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
@@ -201,16 +201,11 @@ public String getPageContents(Context applicationContext) {
201201
*/
202202
private String getTemplatizedCreatedDate() {
203203
if (dateCreated != null) {
204+
java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd");
204205
if (UploadableFile.DateTimeWithSource.EXIF_SOURCE.equals(dateCreatedSource)) {
205-
return String.format(Locale.ENGLISH, TEMPLATE_DATE_ACC_TO_EXIF, DateUtil.getDateStringWithSkeletonPattern(dateCreated, "yyyy-MM-dd")) + "\n";
206+
return String.format(Locale.ENGLISH, TEMPLATE_DATE_ACC_TO_EXIF, dateFormat.format(dateCreated)) + "\n";
206207
} else {
207-
Calendar calendar = Calendar.getInstance();
208-
calendar.setTime(dateCreated);
209-
calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
210-
return String.format(Locale.ENGLISH, TEMPLATE_DATA_OTHER_SOURCE,
211-
calendar.get(Calendar.YEAR),
212-
calendar.get(Calendar.MONTH),
213-
calendar.get(Calendar.DAY_OF_MONTH)) + "\n";
208+
return String.format(Locale.ENGLISH, TEMPLATE_DATA_OTHER_SOURCE, dateFormat.format(dateCreated)) + "\n";
214209
}
215210
}
216211
return "";

0 commit comments

Comments
 (0)