modified date format (#2341)

* modified date format

* mediadetail fragment modified

* added the function in dateutils

* modified imports
This commit is contained in:
Vanshika Arora 2019-01-29 16:34:18 +05:30 committed by Vivek Maskara
parent 34829938a0
commit f38feda896
3 changed files with 16 additions and 3 deletions

View file

@ -12,6 +12,7 @@ import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.Html;
import android.text.TextUtils;
import android.text.format.DateFormat;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
@ -53,6 +54,7 @@ import fr.free.nrw.commons.location.LatLng;
import fr.free.nrw.commons.mwapi.MediaWikiApi;
import fr.free.nrw.commons.ui.widget.CompatTextView;
import timber.log.Timber;
import fr.free.nrw.commons.utils.DateUtils;
import static android.content.Context.CLIPBOARD_SERVICE;
import static android.view.View.GONE;
@ -518,8 +520,7 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment {
if (date == null || date.toString() == null || date.toString().isEmpty()) {
return "Uploaded date not available";
}
SimpleDateFormat formatter = new SimpleDateFormat("dd MMM yyyy", Locale.getDefault());
return formatter.format(date);
return DateUtils.dateInLocaleFormat(date);
}
/**

View file

@ -1,5 +1,7 @@
package fr.free.nrw.commons.utils;
import android.text.format.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
@ -41,4 +43,14 @@ public class DateUtils {
Date date = new Date();
return dateFormat.format(date);
}
public static String dateInLocaleFormat(Date date){
String formatter;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
formatter = new SimpleDateFormat(DateFormat.getBestDateTimePattern(Locale.getDefault(), "dd MMM yyyy"), Locale.getDefault()).format(date);
}
else {
formatter = String.valueOf(new SimpleDateFormat("dd MMM yyyy", Locale.getDefault()));
}
return formatter;
}
}

View file

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip