List of usage examples for java.text SimpleDateFormat applyLocalizedPattern
public void applyLocalizedPattern(String pattern)
From source file:com.customdatepicker.date.MonthView.java
@NonNull private String getMonthAndYearString() { Locale locale = Locale.getDefault(); String pattern = "MMMM yyyy"; if (Build.VERSION.SDK_INT < 18) pattern = getContext().getResources().getString(R.string.mdtp_date_v1_monthyear); else//from ww w. jav a 2 s . co m pattern = DateFormat.getBestDateTimePattern(locale, pattern); SimpleDateFormat formatter = new SimpleDateFormat(pattern, locale); formatter.setTimeZone(mController.getTimeZone()); formatter.applyLocalizedPattern(pattern); mStringBuilder.setLength(0); return formatter.format(mCalendar.getTime()); }
From source file:com.layernet.thaidatetimepicker.date.MonthView.java
@NonNull private String getMonthAndYearString() { /** thai calender edit */ String pattern = "MMMM"; if (Build.VERSION.SDK_INT > 17) pattern = DateFormat.getBestDateTimePattern(locale, pattern); SimpleDateFormat formatter = new SimpleDateFormat(pattern, locale); formatter.applyLocalizedPattern(pattern); mStringBuilder.setLength(0);/* w w w .j a v a 2 s .c o m*/ return formatter.format(mCalendar.getTime()) + " " + getContext().getString(R.string.mdtp_buddhist) + " " + (mCalendar.get(Calendar.YEAR) + BUDDHIST_OFFSET); // Thai calendar edit }
From source file:com.bw.luzz.monkeyapplication.View.DateTimePicker.date.MonthView.java
@NonNull private String getMonthAndYearString() { Locale locale = Locale.getDefault(); String pattern = "MMMM yyyy"; if (Build.VERSION.SDK_INT < 18) pattern = getContext().getResources().getString(R.string.mdtp_date_v1_monthyear); else/*w ww . java2s . co m*/ pattern = DateFormat.getBestDateTimePattern(locale, pattern); SimpleDateFormat formatter = new SimpleDateFormat(pattern, locale); formatter.applyLocalizedPattern(pattern); mStringBuilder.setLength(0); return formatter.format(mCalendar.getTime()); }
From source file:com.jarklee.materialdatetimepicker.date.MonthView.java
@NonNull private String getMonthAndYearString() { String pattern = "MMMM yyyy"; if (Build.VERSION.SDK_INT < 18) pattern = getContext().getResources().getString(R.string.mdtp_date_v1_monthyear); else/*from w ww . java2 s. co m*/ pattern = DateFormat.getBestDateTimePattern(getLocale(), pattern); SimpleDateFormat formatter = new SimpleDateFormat(pattern, getLocale()); formatter.applyLocalizedPattern(pattern); mStringBuilder.setLength(0); return formatter.format(mCalendar.getTime()); }
From source file:com.ibm.mil.readyapps.physio.fragments.ProgressFragment.java
private void gatherDetailedData(List<Integer> data, String route, StringBuilder builder) { Locale locale = getResources().getConfiguration().locale; NumberFormat numberFormat = NumberFormat.getNumberInstance(locale); // set performance String performance = numberFormat.format(data.get(data.size() - 1)); builder.append("scope.setPerformance('"); builder.append(performance);//from w w w. j av a 2s . co m builder.append("');"); // set time frame String format; String unit; String timeSpan = route.split("_")[2]; switch (timeSpan) { case "day": format = "MMMM d - ha"; unit = "Today"; break; case "week": format = "MMMM d"; unit = "Today"; break; case "month": format = "MMM d"; unit = "This Week"; break; default: format = "MMMM yyyy"; unit = "This Month"; break; } SimpleDateFormat dateFormat = new SimpleDateFormat(format, locale); String timeFrame = dateFormat.format(new Date()); // add additional time frame text for month if (timeSpan.equals("month")) { Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); calendar.add(Calendar.WEEK_OF_YEAR, -1); dateFormat.applyLocalizedPattern("MMMM d"); timeFrame = dateFormat.format(calendar.getTime()) + " - " + timeFrame; } builder.append("scope.setTimeFrame('"); builder.append(timeFrame); builder.append("');"); builder.append("scope.setUnit('"); builder.append(unit); builder.append("');"); // set optional goal if (route.contains("steps") || route.contains("calories")) { String goal; if (route.contains("steps")) { goal = numberFormat.format(DataManager.getCurrentPatient().getStepGoal()); } else { goal = numberFormat.format(DataManager.getCurrentPatient().getCalorieGoal()); } builder.append("scope.setGoal('"); builder.append(goal); builder.append("');"); } }