List of usage examples for java.text DateFormatSymbols DateFormatSymbols
public DateFormatSymbols()
From source file:org.apache.stratos.common.util.CommonUtil.java
public static String getMonthString(Calendar calendar) { int currentMonth = calendar.get(Calendar.MONTH); String[] monthArr = new DateFormatSymbols().getMonths(); String month = monthArr[currentMonth]; return calendar.get(Calendar.YEAR) + "-" + month; }
From source file:com.sudhirkhanger.app.popularmovies.DetailFragment.java
private String getMonth(String date) { String monthNum = date.substring(5, 7); int num = Integer.parseInt(monthNum); return new DateFormatSymbols().getMonths()[num - 1]; }
From source file:com.todoroo.astrid.repeats.RepeatControlSet.java
@Nullable @Override//w w w . ja v a 2s . co m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = super.onCreateView(inflater, container, savedInstanceState); if (savedInstanceState != null) { recurrence = savedInstanceState.getString(EXTRA_RECURRENCE); repeatUntilValue = savedInstanceState.getLong(EXTRA_REPEAT_UNTIL); repeatAfterCompletion = savedInstanceState.getBoolean(EXTRA_REPEAT_AFTER_COMPLETION); } dialogView = inflater.inflate(R.layout.control_set_repeat, null); value = (Button) dialogView.findViewById(R.id.repeatValue); Spinner interval = (Spinner) dialogView.findViewById(R.id.repeatInterval); ArrayAdapter<String> intervalAdapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.repeat_interval)); intervalAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); interval.setAdapter(intervalAdapter); Spinner type = (Spinner) dialogView.findViewById(R.id.repeatType); ArrayAdapter<String> typeAdapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.repeat_type)); typeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); type.setAdapter(typeAdapter); type.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { repeatAfterCompletion = position == TYPE_COMPLETION_DATE; } @Override public void onNothingSelected(AdapterView<?> parent) { } }); daysOfWeekContainer = (LinearLayout) dialogView.findViewById(R.id.repeatDayOfWeekContainer); repeatUntil = (Spinner) dialogView.findViewById(R.id.repeat_until); repeatUntilAdapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, repeatUntilOptions); repeatUntilAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); repeatUntil.setAdapter(repeatUntilAdapter); // set up days of week DateFormatSymbols dfs = new DateFormatSymbols(); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_WEEK, calendar.getFirstDayOfWeek()); CompoundButton[] daysOfWeek = new CompoundButton[7]; for (int i = 0; i < 7; i++) { final int index = i; CheckBox checkBox = (CheckBox) daysOfWeekContainer.getChildAt(i); checkBox.setOnCheckedChangeListener( (buttonView, isChecked1) -> RepeatControlSet.this.isChecked[index] = isChecked1); int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); checkBox.setText(dfs.getShortWeekdays()[dayOfWeek].substring(0, 1)); daysOfWeek[i] = checkBox; weekdays[i] = Weekday.values()[dayOfWeek - 1]; calendar.add(Calendar.DATE, 1); } // set up listeners value.setOnClickListener(v -> repeatValueClick()); setRepeatValue(1); interval.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parentView, View view, int position, long id) { daysOfWeekContainer.setVisibility(position == INTERVAL_WEEKS ? View.VISIBLE : View.GONE); intervalValue = position; } @Override public void onNothingSelected(AdapterView<?> arg0) { // } }); setRepeatUntilValue(repeatUntilValue); repeatUntil.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { if (repeatUntilOptions.size() == 2) { if (i == 0) { setRepeatUntilValue(0); } else { repeatUntilClick(); } } else { if (i == 1) { setRepeatUntilValue(0); } else if (i == 2) { repeatUntilClick(); } } } @Override public void onNothingSelected(AdapterView<?> adapterView) { // } }); daysOfWeekContainer.setVisibility(View.GONE); type.setSelection(repeatAfterCompletion ? TYPE_COMPLETION_DATE : TYPE_DUE_DATE); doRepeat = !Strings.isNullOrEmpty(recurrence); if (doRepeat) { // read recurrence rule try { RRule rrule = new RRule(recurrence); setRepeatValue(rrule.getInterval()); for (WeekdayNum day : rrule.getByDay()) { for (int i = 0; i < 7; i++) { if (weekdays[i].equals(day.wday)) { daysOfWeek[i].setChecked(true); } } } switch (rrule.getFreq()) { case DAILY: intervalValue = INTERVAL_DAYS; break; case WEEKLY: intervalValue = INTERVAL_WEEKS; break; case MONTHLY: intervalValue = INTERVAL_MONTHS; break; case HOURLY: intervalValue = INTERVAL_HOURS; break; case MINUTELY: intervalValue = INTERVAL_MINUTES; break; case YEARLY: intervalValue = INTERVAL_YEARS; break; default: Timber.e(new Exception("Unhandled rrule frequency: " + recurrence), "repeat-unhandled-rule"); } interval.setSelection(intervalValue); } catch (Exception e) { // invalid RRULE recurrence = ""; //$NON-NLS-1$ Timber.e(e, e.getMessage()); } } refreshDisplayView(); return view; }
From source file:com.philliphsu.bottomsheetpickers.time.numberpad.NumberPadTimePicker.java
void setIs24HourMode(boolean is24HourMode) { mIs24HourMode = is24HourMode;/* ww w . j a v a 2 s . c o m*/ if (is24HourMode) { mAltButtons[0].setText(R.string.bsp_left_alt_24hr); mAltButtons[1].setText(R.string.bsp_right_alt_24hr); } else { String[] amPm = new DateFormatSymbols().getAmPmStrings(); mAltButtons[0].setText(amPm[0].length() > 2 ? "AM" : amPm[0]); mAltButtons[1].setText(amPm[1].length() > 2 ? "PM" : amPm[1]); } updateNumpadStates(); }
From source file:com.diandi.widget.googledatetimepicker.time.TimePickerDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); View view = inflater.inflate(R.layout.time_picker_dialog, null); KeyboardListener keyboardListener = new KeyboardListener(); view.findViewById(R.id.time_picker_dialog).setOnKeyListener(keyboardListener); Resources res = getResources(); mHourPickerDescription = res.getString(R.string.hour_picker_description); mSelectHours = res.getString(R.string.select_hours); mMinutePickerDescription = res.getString(R.string.minute_picker_description); mSelectMinutes = res.getString(R.string.select_minutes); mBlue = res.getColor(R.color.blue);/*from www . j av a2 s.c o m*/ mBlack = res.getColor(R.color.numbers_text_color); mHourView = (TextView) view.findViewById(R.id.hours); mHourView.setOnKeyListener(keyboardListener); mHourSpaceView = (TextView) view.findViewById(R.id.hour_space); mMinuteSpaceView = (TextView) view.findViewById(R.id.minutes_space); mMinuteView = (TextView) view.findViewById(R.id.minutes); mMinuteView.setOnKeyListener(keyboardListener); mAmPmTextView = (TextView) view.findViewById(R.id.ampm_label); mAmPmTextView.setOnKeyListener(keyboardListener); String[] amPmTexts = new DateFormatSymbols().getAmPmStrings(); mAmText = amPmTexts[0]; mPmText = amPmTexts[1]; mTimePicker = (RadialPickerLayout) view.findViewById(R.id.time_picker); mTimePicker.setOnValueSelectedListener(this); mTimePicker.setOnKeyListener(keyboardListener); mTimePicker.initialize(getActivity(), mInitialHourOfDay, mInitialMinute, mIs24HourMode); int currentItemShowing = HOUR_INDEX; if (savedInstanceState != null && savedInstanceState.containsKey(KEY_CURRENT_ITEM_SHOWING)) { currentItemShowing = savedInstanceState.getInt(KEY_CURRENT_ITEM_SHOWING); } setCurrentItemShowing(currentItemShowing, false, true, true); mTimePicker.invalidate(); mHourView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setCurrentItemShowing(HOUR_INDEX, true, false, true); mTimePicker.tryVibrate(); } }); mMinuteView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setCurrentItemShowing(MINUTE_INDEX, true, false, true); mTimePicker.tryVibrate(); } }); mDoneButton = (TextView) view.findViewById(R.id.done_button); mDoneButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mInKbMode && isTypedTimeFullyLegal()) { finishKbMode(false); } else { mTimePicker.tryVibrate(); } if (mCallback != null) { mCallback.onTimeSet(mTimePicker, mTimePicker.getHours(), mTimePicker.getMinutes()); } dismiss(); } }); mDoneButton.setOnKeyListener(keyboardListener); // Enable or disable the AM/PM view. mAmPmHitspace = view.findViewById(R.id.ampm_hitspace); if (mIs24HourMode) { mAmPmTextView.setVisibility(View.GONE); RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); paramsSeparator.addRule(RelativeLayout.CENTER_IN_PARENT); TextView separatorView = (TextView) view.findViewById(R.id.separator); separatorView.setLayoutParams(paramsSeparator); } else { mAmPmTextView.setVisibility(View.VISIBLE); updateAmPmDisplay(mInitialHourOfDay < 12 ? AM : PM); mAmPmHitspace.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mTimePicker.tryVibrate(); int amOrPm = mTimePicker.getIsCurrentlyAmOrPm(); if (amOrPm == AM) { amOrPm = PM; } else if (amOrPm == PM) { amOrPm = AM; } updateAmPmDisplay(amOrPm); mTimePicker.setAmOrPm(amOrPm); } }); } mAllowAutoAdvance = true; setHour(mInitialHourOfDay, true); setMinute(mInitialMinute); // Set up for keyboard mode. mDoublePlaceholderText = res.getString(R.string.time_placeholder); mDeletedKeyFormat = res.getString(R.string.deleted_key); mPlaceholderText = mDoublePlaceholderText.charAt(0); mAmKeyCode = mPmKeyCode = -1; generateLegalTimesTree(); if (mInKbMode) { mTypedTimes = savedInstanceState.getIntegerArrayList(KEY_TYPED_TIMES); tryStartingKbMode(-1); mHourView.invalidate(); } else if (mTypedTimes == null) { mTypedTimes = new ArrayList<Integer>(); } return view; }
From source file:org.tolven.analysis.bean.PercentTimeSeriesBean.java
private JFreeChart getChart(String dataSeriesTitle, String targetSeriesTitle, List<MenuData> snapshots, Date fromDate, Date toDate, Class<?> intervalUnitClass) { TimeSeries dataTimeSeries = new TimeSeries(dataSeriesTitle); TimeSeries targetTimeSeries = null;/*from www .j a va2 s . c om*/ if (targetSeriesTitle != null) { targetTimeSeries = new TimeSeries(targetSeriesTitle); } for (MenuData snapshot : snapshots) { Date snapshotDate = snapshot.getDate01(); long nSnapshotresultsNumerator = snapshot.getLongField("normCount"); long nSnapshotresultsDenominator = snapshot.getLongField("allCount"); Double value = null; if (nSnapshotresultsDenominator == 0) { value = 0d; } else { value = 1d * nSnapshotresultsNumerator / nSnapshotresultsDenominator; } RegularTimePeriod regTimePeriod = RegularTimePeriod.createInstance(intervalUnitClass, snapshotDate, TimeZone.getDefault()); dataTimeSeries.addOrUpdate(regTimePeriod, value); if (targetTimeSeries != null) { Double targetPercent = snapshot.getDoubleField("targetPercent") / 100; targetTimeSeries.addOrUpdate(regTimePeriod, targetPercent); } } TimeSeriesCollection timeSeriesCollection = new TimeSeriesCollection(); timeSeriesCollection.addSeries(dataTimeSeries); if (targetTimeSeries != null) { timeSeriesCollection.addSeries(targetTimeSeries); } XYDataset xyDataset = (XYDataset) timeSeriesCollection; JFreeChart chart = ChartFactory.createTimeSeriesChart(null, // title null, // x-axis label null, // y-axis label xyDataset, // data true, // create legend? false, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.BLACK); plot.setDomainGridlinesVisible(false); XYItemRenderer r = plot.getRenderer(); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setSeriesShape(0, new Ellipse2D.Double(-3, -3, 6, 6)); renderer.setSeriesPaint(0, Color.BLUE); renderer.setSeriesShape(1, new Rectangle2D.Double(-3, -3, 6, 6)); renderer.setSeriesPaint(1, Color.RED); NumberAxis vaxis = (NumberAxis) plot.getRangeAxis(); vaxis.setAutoRange(true); vaxis.setAxisLineVisible(true); vaxis.setNumberFormatOverride(NumberFormat.getPercentInstance()); vaxis.setTickMarksVisible(true); DateAxis daxis = (DateAxis) plot.getDomainAxis(); daxis.setRange(fromDate, toDate); if (intervalUnitClass == Month.class) { DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(); dateFormatSymbols .setShortMonths(new String[] { "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D" }); daxis.setDateFormatOverride(new SimpleDateFormat("MMM", dateFormatSymbols)); } return chart; }
From source file:com.money.manager.ex.core.Core.java
/** * Return arrays of month formatted and localized * @return arrays of months/*from w w w. j a va2s.com*/ */ public String[] getListMonths() { return new DateFormatSymbols().getMonths(); }
From source file:org.aksw.simba.bengal.triple2nl.converter.LiteralConverter.java
public String getMonthName(int month) { return new DateFormatSymbols().getMonths()[month - 1]; }
From source file:com.wecook.uikit.widget.datetimepicker.time.TimePickerDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); View view = inflater.inflate(R.layout.time_picker_dialogs, container); KeyboardListener keyboardListener = new KeyboardListener(); LinearLayout ly = (LinearLayout) view.findViewById(R.id.picker_dialog); ly.setOnKeyListener(keyboardListener); Resources res = getResources(); mHourPickerDescription = res.getString(R.string.hour_picker_description); mSelectHours = res.getString(R.string.select_hours); mMinutePickerDescription = res.getString(R.string.minute_picker_description); mSelectMinutes = res.getString(R.string.select_minutes); mBlue = res.getColor(R.color.blue);/* w ww . jav a 2 s . c o m*/ mBlack = res.getColor(R.color.numbers_text_color); mHourView = (TextView) view.findViewById(R.id.hours); mHourView.setOnKeyListener(keyboardListener); mHourSpaceView = (TextView) view.findViewById(R.id.hour_space); mMinuteSpaceView = (TextView) view.findViewById(R.id.minutes_space); mMinuteView = (TextView) view.findViewById(R.id.minutes); mMinuteView.setOnKeyListener(keyboardListener); mAmPmTextView = (TextView) view.findViewById(R.id.ampm_label); mAmPmTextView.setOnKeyListener(keyboardListener); String[] amPmTexts = new DateFormatSymbols().getAmPmStrings(); mAmText = amPmTexts[0]; mPmText = amPmTexts[1]; mTimePicker = (RadialPickerLayout) view.findViewById(R.id.time_picker); mTimePicker.setOnValueSelectedListener(this); mTimePicker.setOnKeyListener(keyboardListener); mTimePicker.initialize(getActivity(), mInitialHourOfDay, mInitialMinute, mIs24HourMode); int currentItemShowing = HOUR_INDEX; if (savedInstanceState != null && savedInstanceState.containsKey(KEY_CURRENT_ITEM_SHOWING)) { currentItemShowing = savedInstanceState.getInt(KEY_CURRENT_ITEM_SHOWING); } setCurrentItemShowing(currentItemShowing, false, true, true); mTimePicker.invalidate(); mHourView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setCurrentItemShowing(HOUR_INDEX, true, false, true); mTimePicker.tryVibrate(); } }); mMinuteView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setCurrentItemShowing(MINUTE_INDEX, true, false, true); mTimePicker.tryVibrate(); } }); mDoneButton = (TextView) view.findViewById(R.id.done_button); mDoneButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mInKbMode && isTypedTimeFullyLegal()) { finishKbMode(false); } else { mTimePicker.tryVibrate(); } if (mCallback != null) { mCallback.onTimeSet(mTimePicker, mTimePicker.getHours(), mTimePicker.getMinutes()); } dismiss(); } }); mDoneButton.setOnKeyListener(keyboardListener); // Enable or disable the AM/PM view. mAmPmHitspace = view.findViewById(R.id.ampm_hitspace); if (mIs24HourMode) { mAmPmTextView.setVisibility(View.GONE); RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); paramsSeparator.addRule(RelativeLayout.CENTER_IN_PARENT); TextView separatorView = (TextView) view.findViewById(R.id.separator); separatorView.setLayoutParams(paramsSeparator); } else { mAmPmTextView.setVisibility(View.VISIBLE); updateAmPmDisplay(mInitialHourOfDay < 12 ? AM : PM); mAmPmHitspace.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mTimePicker.tryVibrate(); int amOrPm = mTimePicker.getIsCurrentlyAmOrPm(); if (amOrPm == AM) { amOrPm = PM; } else if (amOrPm == PM) { amOrPm = AM; } updateAmPmDisplay(amOrPm); mTimePicker.setAmOrPm(amOrPm); } }); } mAllowAutoAdvance = true; setHour(mInitialHourOfDay, true); setMinute(mInitialMinute); // Set up for keyboard mode. mDoublePlaceholderText = res.getString(R.string.time_placeholder); mDeletedKeyFormat = res.getString(R.string.deleted_key); mPlaceholderText = mDoublePlaceholderText.charAt(0); mAmKeyCode = mPmKeyCode = -1; generateLegalTimesTree(); if (mInKbMode) { mTypedTimes = savedInstanceState.getIntegerArrayList(KEY_TYPED_TIMES); tryStartingKbMode(-1); mHourView.invalidate(); } else if (mTypedTimes == null) { mTypedTimes = new ArrayList<Integer>(); } return view; }