Skip to content

Commit

Permalink
Merge pull request #501 from accandme/patch-1
Browse files Browse the repository at this point in the history
Localize Date Format
  • Loading branch information
alamkanak committed Jul 16, 2020
2 parents dc3f97d + 22698a0 commit 2ac4440
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions library/src/main/java/com/alamkanak/weekview/WeekView.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.format.DateFormat;
import android.text.format.DateUtils;
import android.text.style.StyleSpan;
import android.util.AttributeSet;
import android.util.TypedValue;
Expand Down Expand Up @@ -1302,8 +1303,10 @@ public DateTimeInterpreter getDateTimeInterpreter() {
@Override
public String interpretDate(Calendar date) {
try {
SimpleDateFormat sdf = mDayNameLength == LENGTH_SHORT ? new SimpleDateFormat("EEEEE M/dd", Locale.getDefault()) : new SimpleDateFormat("EEE M/dd", Locale.getDefault());
return sdf.format(date.getTime()).toUpperCase();
int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NO_YEAR | DateUtils.FORMAT_NUMERIC_DATE;
String localizedDate = DateUtils.formatDateTime(getContext(), date.getTime().getTime(), flags);
SimpleDateFormat sdf = mDayNameLength == LENGTH_SHORT ? new SimpleDateFormat("EEEEE", Locale.getDefault()) : new SimpleDateFormat("EEE", Locale.getDefault());
return String.format("%s %s", sdf.format(date.getTime()).toUpperCase(), localizedDate);
} catch (Exception e) {
e.printStackTrace();
return "";
Expand Down

0 comments on commit 2ac4440

Please sign in to comment.