Skip to content

Commit 5a03dbc

Browse files
committed
Internationalize date and time formats
1 parent 6d4a2b0 commit 5a03dbc

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ buildscript {
66
jcenter()
77
}
88
dependencies {
9-
classpath 'com.android.tools.build:gradle:3.5.2'
9+
classpath 'com.android.tools.build:gradle:3.5.3'
1010
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
1111

1212
// NOTE: Do not place your application dependencies here; they belong

library/src/main/java/com/developer/filepicker/controller/adapters/FileListAdapter.java

+8-5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import android.widget.BaseAdapter;
1111
import android.widget.ImageView;
1212
import android.widget.TextView;
13+
1314
import com.developer.filepicker.R;
1415
import com.developer.filepicker.controller.NotifyItemChecked;
1516
import com.developer.filepicker.model.DialogConfigs;
@@ -18,10 +19,10 @@
1819
import com.developer.filepicker.model.MarkedItemList;
1920
import com.developer.filepicker.widget.MaterialCheckbox;
2021
import com.developer.filepicker.widget.OnCheckedChangeListener;
21-
import java.text.SimpleDateFormat;
22+
23+
import java.text.DateFormat;
2224
import java.util.ArrayList;
2325
import java.util.Date;
24-
import java.util.Locale;
2526

2627
/**
2728
* @author akshay sunil masram
@@ -105,14 +106,16 @@ public View getView(final int i, View view, ViewGroup viewGroup) {
105106
}
106107
holder.type_icon.setContentDescription(item.getFilename());
107108
holder.name.setText(item.getFilename());
108-
SimpleDateFormat sdate = new SimpleDateFormat("dd/MM/yyyy", Locale.getDefault());
109-
SimpleDateFormat stime = new SimpleDateFormat("hh:mm aa", Locale.getDefault());
109+
DateFormat dateFormatter = android.text.format.DateFormat.getMediumDateFormat(context);
110+
DateFormat timeFormatter = android.text.format.DateFormat.getTimeFormat(context);
111+
//SimpleDateFormat sdate = new SimpleDateFormat("dd/MM/yyyy", Locale.getDefault());
112+
//SimpleDateFormat stime = new SimpleDateFormat("hh:mm aa", Locale.getDefault());
110113
Date date = new Date(item.getTime());
111114
if(i==0&&item.getFilename().startsWith(context.getString(R.string.label_parent_dir))) {
112115
holder.type.setText(R.string.label_parent_directory);
113116
}
114117
else {
115-
holder.type.setText(context.getString(R.string.last_edit) + sdate.format(date) + ", " + stime.format(date));
118+
holder.type.setText(String.format(context.getString(R.string.last_edit), dateFormatter.format(date), timeFormatter.format(date)));
116119
}
117120
if(holder.fmark.getVisibility()==View.VISIBLE) {
118121
if(i==0&&item.getFilename().startsWith(context.getString(R.string.label_parent_dir)))

library/src/main/res/values/strings.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<string name="choose_button_label">Select</string>
55
<string name="default_dir" translatable="false">/sdcard</string>
66
<string name="label_parent_directory">Parent Directory</string>
7-
<string name="last_edit">Last edited: </string>
7+
<string name="last_edit">Last edited: %1$s, %2$s</string>
88
<string name="error_dir_access">Directory cannot be accessed</string>
99
<string name="label_parent_dir" translatable="false">..</string>
1010
</resources>

0 commit comments

Comments
 (0)