Example usage for java.text DateFormatSymbols DateFormatSymbols

List of usage examples for java.text DateFormatSymbols DateFormatSymbols

Introduction

In this page you can find the example usage for java.text DateFormatSymbols DateFormatSymbols.

Prototype

private DateFormatSymbols(boolean flag) 

Source Link

Document

Constructs an uninitialized DateFormatSymbols.

Usage

From source file:com.redinput.datetimepickercompat.date.DayPickerView.java

private String getMonthAndYearString(CalendarDay day) {
    Calendar cal = Calendar.getInstance();
    cal.set(day.year, day.month, day.day);

    StringBuffer sbuf = new StringBuffer();
    sbuf.append(new DateFormatSymbols(Locale.getDefault()).getWeekdays()[cal.get(Calendar.MONTH)]);
    sbuf.append(" ");
    sbuf.append(YEAR_FORMAT.format(cal.getTime()));
    return sbuf.toString();
}

From source file:org.sakaiproject.tool.section.jsf.backingbean.AddSectionsBean.java

protected void initDaysOfWeek() {
    ResourceLoader rl = new ResourceLoader();
    DateFormatSymbols dfs = new DateFormatSymbols(rl.getLocale());
    daysOfWeek = dfs.getWeekdays();/*from w w w  .j a  va  2  s. c  o  m*/
}

From source file:org.pentaho.plugin.jfreereport.reportcharts.XYChartExpression.java

protected void configureChart(final JFreeChart chart) {
    super.configureChart(chart);

    final XYPlot plot = chart.getXYPlot();
    final XYItemRenderer renderer = plot.getRenderer();

    if (StringUtils.isEmpty(getTooltipFormula()) == false) {
        renderer.setBaseToolTipGenerator(new FormulaXYZTooltipGenerator(getRuntime(), getTooltipFormula()));
    }//from   w  ww.ja  v  a2s.  co  m
    if (StringUtils.isEmpty(getUrlFormula()) == false) {
        renderer.setURLGenerator(new FormulaXYZURLGenerator(getRuntime(), getUrlFormula()));
    }

    renderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
    renderer.setBaseItemLabelsVisible(Boolean.TRUE.equals(getItemsLabelVisible()));
    if (getItemLabelFont() != null) {
        renderer.setBaseItemLabelFont(getItemLabelFont());
    }

    plot.setOrientation(computePlotOrientation());

    // May be an axis that supports dates
    final ValueAxis domainAxis = plot.getDomainAxis();
    if (domainAxis instanceof NumberAxis) {
        final NumberAxis numberAxis = (NumberAxis) domainAxis;
        numberAxis.setAutoRangeIncludesZero(isDomainIncludesZero());
        numberAxis.setAutoRangeStickyZero(isDomainStickyZero());
        if (getDomainPeriodCount() > 0) {
            if (getDomainTickFormat() != null) {
                numberAxis.setTickUnit(new NumberTickUnit(getDomainPeriodCount(), getDomainTickFormat()));
            } else if (getDomainTickFormatString() != null) {
                final FastDecimalFormat formatter = new FastDecimalFormat(getDomainTickFormatString(),
                        getResourceBundleFactory().getLocale());
                numberAxis.setTickUnit(new FastNumberTickUnit(getDomainPeriodCount(), formatter));
            } else {
                numberAxis.setTickUnit(new FastNumberTickUnit(getDomainPeriodCount()));
            }
        } else {
            if (getDomainTickFormat() != null) {
                numberAxis.setNumberFormatOverride(getDomainTickFormat());
            } else if (getDomainTickFormatString() != null) {
                final DecimalFormat formatter = new DecimalFormat(getDomainTickFormatString(),
                        new DecimalFormatSymbols(getResourceBundleFactory().getLocale()));
                numberAxis.setNumberFormatOverride(formatter);
            }
        }
    } else if (domainAxis instanceof DateAxis) {
        final DateAxis numberAxis = (DateAxis) domainAxis;

        if (getDomainPeriodCount() > 0 && getDomainTimePeriod() != null) {
            if (getDomainTickFormatString() != null) {
                final SimpleDateFormat formatter = new SimpleDateFormat(getDomainTickFormatString(),
                        new DateFormatSymbols(getResourceBundleFactory().getLocale()));
                numberAxis.setTickUnit(new DateTickUnit(getDateUnitAsInt(getDomainTimePeriod()),
                        (int) getDomainPeriodCount(), formatter));
            } else {
                numberAxis.setTickUnit(new DateTickUnit(getDateUnitAsInt(getDomainTimePeriod()),
                        (int) getDomainPeriodCount()));
            }
        }
    }

    if (domainAxis != null) {
        domainAxis.setLabel(getDomainTitle());
        if (getDomainTitleFont() != null) {
            domainAxis.setLabelFont(getDomainTitleFont());
        }
        domainAxis.setVerticalTickLabels(isDomainVerticalTickLabels());
        if (getDomainTickFont() != null) {
            domainAxis.setTickLabelFont(getDomainTickFont());
        }
        final int level = getRuntime().getProcessingContext().getCompatibilityLevel();
        if (ClassicEngineBoot.isEnforceCompatibilityFor(level, 3, 8)) {
            if (getDomainMinimum() != 0) {
                domainAxis.setLowerBound(getDomainMinimum());
            }
            if (getDomainMaximum() != 1) {
                domainAxis.setUpperBound(getDomainMaximum());
            }
            if (getDomainMinimum() == 0 && getDomainMaximum() == 0) {
                domainAxis.setLowerBound(0);
                domainAxis.setUpperBound(1);
                domainAxis.setAutoRange(true);
            }
        } else {
            domainAxis.setLowerBound(getDomainMinimum());
            domainAxis.setUpperBound(getDomainMaximum());
            domainAxis.setAutoRange(isDomainAxisAutoRange());
        }
    }

    final ValueAxis rangeAxis = plot.getRangeAxis();
    if (rangeAxis instanceof NumberAxis) {
        final NumberAxis numberAxis = (NumberAxis) rangeAxis;
        numberAxis.setAutoRangeIncludesZero(isRangeIncludesZero());
        numberAxis.setAutoRangeStickyZero(isRangeStickyZero());

        if (getRangePeriodCount() > 0) {
            if (getRangeTickFormat() != null) {
                numberAxis.setTickUnit(new NumberTickUnit(getRangePeriodCount(), getRangeTickFormat()));
            } else if (getRangeTickFormatString() != null) {
                final FastDecimalFormat formatter = new FastDecimalFormat(getRangeTickFormatString(),
                        getResourceBundleFactory().getLocale());
                numberAxis.setTickUnit(new FastNumberTickUnit(getRangePeriodCount(), formatter));
            } else {
                numberAxis.setTickUnit(new FastNumberTickUnit(getRangePeriodCount()));
            }
        } else {
            if (getRangeTickFormat() != null) {
                numberAxis.setNumberFormatOverride(getRangeTickFormat());
            } else if (getRangeTickFormatString() != null) {
                final DecimalFormat formatter = new DecimalFormat(getRangeTickFormatString(),
                        new DecimalFormatSymbols(getResourceBundleFactory().getLocale()));
                numberAxis.setNumberFormatOverride(formatter);
                standardTickUnitsApplyFormat(numberAxis, formatter);
            }
        }
    } else if (rangeAxis instanceof DateAxis) {
        final DateAxis numberAxis = (DateAxis) rangeAxis;

        if (getRangePeriodCount() > 0 && getRangeTimePeriod() != null) {
            if (getRangeTickFormatString() != null) {
                final SimpleDateFormat formatter = new SimpleDateFormat(getRangeTickFormatString(),
                        new DateFormatSymbols(getResourceBundleFactory().getLocale()));
                numberAxis.setTickUnit(new DateTickUnit(getDateUnitAsInt(getRangeTimePeriod()),
                        (int) getRangePeriodCount(), formatter));
            } else {
                numberAxis.setTickUnit(
                        new DateTickUnit(getDateUnitAsInt(getRangeTimePeriod()), (int) getRangePeriodCount()));
            }
        } else {
            if (getRangeTickFormatString() != null) {
                final SimpleDateFormat formatter = new SimpleDateFormat(getRangeTickFormatString(),
                        new DateFormatSymbols(getResourceBundleFactory().getLocale()));
                numberAxis.setDateFormatOverride(formatter);
            }
        }
    }

    if (rangeAxis != null) {
        rangeAxis.setLabel(getRangeTitle());
        if (getRangeTitleFont() != null) {
            rangeAxis.setLabelFont(getRangeTitleFont());
        }
        if (getRangeTickFont() != null) {
            rangeAxis.setTickLabelFont(getRangeTickFont());
        }
        final int level = getRuntime().getProcessingContext().getCompatibilityLevel();
        if (ClassicEngineBoot.isEnforceCompatibilityFor(level, 3, 8)) {
            if (getRangeMinimum() != 0) {
                rangeAxis.setLowerBound(getRangeMinimum());
            }
            if (getRangeMaximum() != 1) {
                rangeAxis.setUpperBound(getRangeMaximum());
            }
            if (getRangeMinimum() == 0 && getRangeMaximum() == 0) {
                rangeAxis.setLowerBound(0);
                rangeAxis.setUpperBound(1);
                rangeAxis.setAutoRange(true);
            }
        } else {
            rangeAxis.setLowerBound(getRangeMinimum());
            rangeAxis.setUpperBound(getRangeMaximum());
            rangeAxis.setAutoRange(isRangeAxisAutoRange());
        }
    }

    final String[] colors = getSeriesColor();
    for (int i = 0; i < colors.length; i++) {
        renderer.setSeriesPaint(i, parseColorFromString(colors[i]));
    }
}

From source file:org.richfaces.renderkit.CalendarRendererBase.java

protected Map<String, String[]> getSymbolsMap(FacesContext facesContext, UICalendar calendar) {
    Map<String, String[]> map = new HashMap<String, String[]>();

    Locale locale = calendar.getAsLocale(calendar.getLocale());
    Calendar cal = calendar.getCalendar();
    int maximum = cal.getActualMaximum(Calendar.DAY_OF_WEEK);
    int minimum = cal.getActualMinimum(Calendar.DAY_OF_WEEK);

    int monthMax = cal.getActualMaximum(Calendar.MONTH);
    int monthMin = cal.getActualMinimum(Calendar.MONTH);

    DateFormatSymbols symbols = new DateFormatSymbols(locale);
    String[] weekDayLabels = ComponentUtil.asArray(calendar.getWeekDayLabels());
    if (weekDayLabels == null) {
        weekDayLabels = symbols.getWeekdays();
        weekDayLabels = shiftDates(minimum, maximum, weekDayLabels);
    }/*w ww .j av a 2 s  .co m*/

    String[] weekDayLabelsShort = ComponentUtil.asArray(calendar.getWeekDayLabelsShort());
    if (weekDayLabelsShort == null) {
        weekDayLabelsShort = symbols.getShortWeekdays();
        weekDayLabelsShort = shiftDates(minimum, maximum, weekDayLabelsShort);
    }

    String[] monthLabels = ComponentUtil.asArray(calendar.getMonthLabels());
    if (monthLabels == null) {
        monthLabels = symbols.getMonths();
        monthLabels = shiftDates(monthMin, monthMax, monthLabels);
    }

    String[] monthLabelsShort = ComponentUtil.asArray(calendar.getMonthLabelsShort());
    if (monthLabelsShort == null) {
        monthLabelsShort = symbols.getShortMonths();
        monthLabelsShort = shiftDates(monthMin, monthMax, monthLabelsShort);
    }

    map.put(WEEK_DAY_LABELS, weekDayLabels);
    map.put(WEEK_DAY_LABELS_SHORT, weekDayLabelsShort);
    map.put(MONTH_LABELS, monthLabels);
    map.put(MONTH_LABELS_SHORT, monthLabelsShort);

    return map;
}

From source file:org.pentaho.plugin.jfreereport.reportcharts.CategoricalChartExpression.java

protected void configureRangeAxis(final CategoryPlot cpl, final Font labelFont) {
    final ValueAxis rangeAxis = cpl.getRangeAxis();
    if (rangeAxis instanceof NumberAxis) {
        final NumberAxis numberAxis = (NumberAxis) rangeAxis;
        numberAxis.setAutoRangeIncludesZero(isRangeIncludesZero());
        numberAxis.setAutoRangeStickyZero(isRangeStickyZero());

        if (getRangePeriodCount() > 0) {
            if (getRangeTickFormat() != null) {
                numberAxis.setTickUnit(new NumberTickUnit(getRangePeriodCount(), getRangeTickFormat()));
            } else if (getRangeTickFormatString() != null) {
                final FastDecimalFormat formatter = new FastDecimalFormat(getRangeTickFormatString(),
                        getResourceBundleFactory().getLocale());
                numberAxis.setTickUnit(new FastNumberTickUnit(getRangePeriodCount(), formatter));
            } else {
                numberAxis.setTickUnit(new FastNumberTickUnit(getRangePeriodCount()));
            }/*from  w w  w.  j  av  a  2 s  .c om*/
        } else {
            if (getRangeTickFormat() != null) {
                numberAxis.setNumberFormatOverride(getRangeTickFormat());
            } else if (getRangeTickFormatString() != null) {
                final DecimalFormat formatter = new DecimalFormat(getRangeTickFormatString(),
                        new DecimalFormatSymbols(getResourceBundleFactory().getLocale()));
                numberAxis.setNumberFormatOverride(formatter);
                standardTickUnitsApplyFormat(numberAxis, formatter);
            }
        }
    } else if (rangeAxis instanceof DateAxis) {
        final DateAxis numberAxis = (DateAxis) rangeAxis;

        if (getRangePeriodCount() > 0 && getRangeTimePeriod() != null) {
            if (getRangeTickFormatString() != null) {
                final SimpleDateFormat formatter = new SimpleDateFormat(getRangeTickFormatString(),
                        new DateFormatSymbols(getResourceBundleFactory().getLocale()));
                numberAxis.setTickUnit(new DateTickUnit(getDateUnitAsInt(getRangeTimePeriod()),
                        (int) getRangePeriodCount(), formatter));
            } else {
                numberAxis.setTickUnit(
                        new DateTickUnit(getDateUnitAsInt(getRangeTimePeriod()), (int) getRangePeriodCount()));
            }
        } else if (getRangeTickFormatString() != null) {
            final SimpleDateFormat formatter = new SimpleDateFormat(getRangeTickFormatString(),
                    new DateFormatSymbols(getResourceBundleFactory().getLocale()));
            numberAxis.setDateFormatOverride(formatter);
        }

    }

    if (rangeAxis != null) {
        rangeAxis.setLabelFont(labelFont);
        rangeAxis.setTickLabelFont(labelFont);

        if (getRangeTitleFont() != null) {
            rangeAxis.setLabelFont(getRangeTitleFont());
        }
        if (getRangeTickFont() != null) {
            rangeAxis.setTickLabelFont(getRangeTickFont());
        }
        final int level = getRuntime().getProcessingContext().getCompatibilityLevel();
        if (ClassicEngineBoot.isEnforceCompatibilityFor(level, 3, 8)) {
            if (getRangeMinimum() != 0) {
                rangeAxis.setLowerBound(getRangeMinimum());
            }
            if (getRangeMaximum() != 1) {
                rangeAxis.setUpperBound(getRangeMaximum());
            }
            if (getRangeMinimum() == 0 && getRangeMaximum() == 0) {
                rangeAxis.setAutoRange(true);
            }
        } else {
            if (isAutoRange()) {
                rangeAxis.setAutoRange(isAutoRange());
            } else {
                double factor = getScaleFactor();
                if (factor > DEFAULT_SCALE_FACTOR) {
                    // PRD-5340 hack
                    // this method is invoked after all series were populated
                    // hence the axis already has the graph's max and min values;
                    double lower = rangeAxis.getLowerBound();
                    if (lower < 0) {
                        lower *= factor;
                    } else if (lower > 0) {
                        lower /= factor;
                    }

                    double upper = rangeAxis.getUpperBound();
                    if (upper > 0) {
                        upper *= factor;
                    } else if (upper < 0) {
                        upper /= factor;
                    }
                    rangeAxis.setRange(lower, upper);
                } else {
                    // the 'scaleFactor' property is left intact or has an incorrect value
                    rangeAxis.setUpperBound(getRangeMaximum());
                    rangeAxis.setLowerBound(getRangeMinimum());
                }
            }
        }
    }
}

From source file:com.jarklee.materialdatetimepicker.time.TimePickerDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.mdtp_time_picker_dialog, container, false);
    KeyboardListener keyboardListener = new KeyboardListener();
    view.findViewById(R.id.time_picker_dialog).setOnKeyListener(keyboardListener);

    // If an accent color has not been set manually, get it from the context
    if (mAccentColor == -1) {
        mAccentColor = Utils.getAccentColorFromThemeIfAvailable(getActivity());
    }//from w  ww  .j  a v  a  2 s .  c  o  m

    // if theme mode has not been set by java code, check if it is specified in Style.xml
    if (!mThemeDarkChanged) {
        mThemeDark = Utils.isDarkTheme(getActivity(), mThemeDark);
    }

    Resources res = getResources();
    Context context = getActivity();
    mHourPickerDescription = res.getString(R.string.mdtp_hour_picker_description);
    mSelectHours = res.getString(R.string.mdtp_select_hours);
    mMinutePickerDescription = res.getString(R.string.mdtp_minute_picker_description);
    mSelectMinutes = res.getString(R.string.mdtp_select_minutes);
    mSecondPickerDescription = res.getString(R.string.mdtp_second_picker_description);
    mSelectSeconds = res.getString(R.string.mdtp_select_seconds);
    mSelectedColor = ContextCompat.getColor(context, R.color.mdtp_white);
    mUnselectedColor = ContextCompat.getColor(context, R.color.mdtp_accent_color_focused);

    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);
    mSecondSpaceView = (TextView) view.findViewById(R.id.seconds_space);
    mSecondView = (TextView) view.findViewById(R.id.seconds);
    mSecondView.setOnKeyListener(keyboardListener);
    mAmPmTextView = (TextView) view.findViewById(R.id.ampm_label);
    mAmPmTextView.setOnKeyListener(keyboardListener);
    String[] amPmTexts = new DateFormatSymbols(getLocale()).getAmPmStrings();
    mAmText = amPmTexts[0];
    mPmText = amPmTexts[1];

    mHapticFeedbackController = new HapticFeedbackController(getActivity());

    if (mTimePicker != null) {
        mInitialTime = new Timepoint(mTimePicker.getHours(), mTimePicker.getMinutes(),
                mTimePicker.getSeconds());
    }

    mInitialTime = roundToNearest(mInitialTime);

    mTimePicker = (RadialPickerLayout) view.findViewById(R.id.time_picker);
    mTimePicker.setOnValueSelectedListener(this);
    mTimePicker.setOnKeyListener(keyboardListener);
    mTimePicker.initialize(getActivity(), this, mInitialTime, 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);
            tryVibrate();
        }
    });
    mMinuteView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setCurrentItemShowing(MINUTE_INDEX, true, false, true);
            tryVibrate();
        }
    });
    mSecondView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            setCurrentItemShowing(SECOND_INDEX, true, false, true);
            tryVibrate();
        }
    });

    mOkButton = (Button) view.findViewById(R.id.ok);
    mOkButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mInKbMode && isTypedTimeFullyLegal()) {
                finishKbMode(false);
            } else {
                tryVibrate();
            }
            notifyOnDateListener();
            dismiss();
        }
    });
    mOkButton.setOnKeyListener(keyboardListener);
    mOkButton.setTypeface(TypefaceHelper.get(context, "Roboto-Medium"));
    if (mOkString != null)
        mOkButton.setText(mOkString);
    else
        mOkButton.setText(Utils.getStringFromLocale(getContext(), mOkResid, getLocale()));

    mCancelButton = (Button) view.findViewById(R.id.cancel);
    mCancelButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            tryVibrate();
            if (getDialog() != null)
                getDialog().cancel();
        }
    });
    mCancelButton.setTypeface(TypefaceHelper.get(context, "Roboto-Medium"));
    if (mCancelString != null)
        mCancelButton.setText(mCancelString);
    else
        mCancelButton.setText(Utils.getStringFromLocale(getContext(), mCancelResid, getLocale()));
    mCancelButton.setVisibility(isCancelable() ? View.VISIBLE : View.GONE);

    // Enable or disable the AM/PM view.
    mAmPmHitspace = view.findViewById(R.id.ampm_hitspace);
    if (mIs24HourMode) {
        mAmPmTextView.setVisibility(View.GONE);
    } else {
        mAmPmTextView.setVisibility(View.VISIBLE);
        updateAmPmDisplay(mInitialTime.isAM() ? AM : PM);
        mAmPmHitspace.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // Don't do anything if either AM or PM are disabled
                if (isAmDisabled() || isPmDisabled())
                    return;

                tryVibrate();
                int amOrPm = mTimePicker.getIsCurrentlyAmOrPm();
                if (amOrPm == AM) {
                    amOrPm = PM;
                } else if (amOrPm == PM) {
                    amOrPm = AM;
                }
                mTimePicker.setAmOrPm(amOrPm);
            }
        });
    }

    // Disable seconds picker
    if (!mEnableSeconds) {
        mSecondView.setVisibility(View.GONE);
        view.findViewById(R.id.separator_seconds).setVisibility(View.GONE);
    }

    // Disable minutes picker
    if (!mEnableMinutes) {
        mMinuteSpaceView.setVisibility(View.GONE);
        view.findViewById(R.id.separator).setVisibility(View.GONE);
    }

    // Center stuff depending on what's visible
    if (mIs24HourMode && !mEnableSeconds && mEnableMinutes) {
        // center first separator
        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 if (!mEnableMinutes && !mEnableSeconds) {
        // center the hour
        RelativeLayout.LayoutParams paramsHour = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsHour.addRule(RelativeLayout.CENTER_IN_PARENT);
        mHourSpaceView.setLayoutParams(paramsHour);

        if (!mIs24HourMode) {
            RelativeLayout.LayoutParams paramsAmPm = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT);
            paramsAmPm.addRule(RelativeLayout.RIGHT_OF, R.id.hour_space);
            paramsAmPm.addRule(RelativeLayout.ALIGN_BASELINE, R.id.hour_space);
            mAmPmTextView.setLayoutParams(paramsAmPm);
        }
    } else if (mEnableSeconds) {
        // link separator to minutes
        final View separator = view.findViewById(R.id.separator);
        RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsSeparator.addRule(RelativeLayout.LEFT_OF, R.id.minutes_space);
        paramsSeparator.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
        separator.setLayoutParams(paramsSeparator);

        if (!mIs24HourMode) {
            // center minutes
            RelativeLayout.LayoutParams paramsMinutes = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            paramsMinutes.addRule(RelativeLayout.CENTER_IN_PARENT);
            mMinuteSpaceView.setLayoutParams(paramsMinutes);
        } else {
            // move minutes to right of center
            RelativeLayout.LayoutParams paramsMinutes = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            paramsMinutes.addRule(RelativeLayout.RIGHT_OF, R.id.center_view);
            mMinuteSpaceView.setLayoutParams(paramsMinutes);
        }
    }

    mAllowAutoAdvance = true;
    setHour(mInitialTime.getHour(), true);
    setMinute(mInitialTime.getMinute());
    setSecond(mInitialTime.getSecond());

    // Set up for keyboard mode.
    mDoublePlaceholderText = res.getString(R.string.mdtp_time_placeholder);
    mDeletedKeyFormat = res.getString(R.string.mdtp_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<>();
    }

    // Set the title (if any)
    TextView timePickerHeader = (TextView) view.findViewById(R.id.time_picker_header);
    if (!mTitle.isEmpty()) {
        timePickerHeader.setVisibility(TextView.VISIBLE);
        timePickerHeader.setText(mTitle.toUpperCase(getLocale()));
    }

    // Set the theme at the end so that the initialize()s above don't counteract the theme.
    mOkButton.setTextColor(mAccentColor);
    mCancelButton.setTextColor(mAccentColor);
    timePickerHeader.setBackgroundColor(Utils.darkenColor(mAccentColor));
    view.findViewById(R.id.time_display_background).setBackgroundColor(mAccentColor);
    view.findViewById(R.id.time_display).setBackgroundColor(mAccentColor);

    if (getDialog() == null) {
        view.findViewById(R.id.done_background).setVisibility(View.GONE);
    }

    int circleBackground = ContextCompat.getColor(context, R.color.mdtp_circle_background);
    int backgroundColor = ContextCompat.getColor(context, R.color.mdtp_background_color);
    int darkBackgroundColor = ContextCompat.getColor(context, R.color.mdtp_light_gray);
    int lightGray = ContextCompat.getColor(context, R.color.mdtp_light_gray);

    mTimePicker.setBackgroundColor(mThemeDark ? lightGray : circleBackground);
    view.findViewById(R.id.time_picker_dialog)
            .setBackgroundColor(mThemeDark ? darkBackgroundColor : backgroundColor);
    return view;
}

From source file:org.sparkcommerce.core.web.processor.OnePageCheckoutProcessor.java

/**
 * A helper method used to construct a list of Credit Card Expiration Months
 * Useful for expiration dropdown menus.
 * Will use locale to determine language if a locale is available.
 *
 * @return List containing expiration months of the form "01 - January"
 *//*from www.ja  va2  s .c  o  m*/
protected List<String> populateExpirationMonths() {
    DateFormatSymbols dateFormatter;
    if (SparkRequestContext.hasLocale()) {
        Locale locale = SparkRequestContext.getSparkRequestContext().getJavaLocale();
        dateFormatter = new DateFormatSymbols(locale);
    } else {
        dateFormatter = new DateFormatSymbols();
    }
    List<String> expirationMonths = new ArrayList<String>();
    NumberFormat formatter = new DecimalFormat("00");
    String[] months = dateFormatter.getMonths();
    for (int i = 1; i < months.length; i++) {
        expirationMonths.add(formatter.format(i) + " - " + months[i - 1]);
    }
    return expirationMonths;
}

From source file:org.broadleafcommerce.core.web.processor.OnePageCheckoutProcessor.java

/**
 * A helper method used to construct a list of Credit Card Expiration Months
 * Useful for expiration dropdown menus.
 * Will use locale to determine language if a locale is available.
 *
 * @return List containing expiration months of the form "01 - January"
 *///from w w w  . j a  va2  s . c  om
protected List<String> populateExpirationMonths() {
    DateFormatSymbols dateFormatter;
    if (BroadleafRequestContext.hasLocale()) {
        Locale locale = BroadleafRequestContext.getBroadleafRequestContext().getJavaLocale();
        dateFormatter = new DateFormatSymbols(locale);
    } else {
        dateFormatter = new DateFormatSymbols();
    }
    List<String> expirationMonths = new ArrayList<String>();
    NumberFormat formatter = new DecimalFormat("00");
    String[] months = dateFormatter.getMonths();
    for (int i = 1; i < months.length; i++) {
        expirationMonths.add(formatter.format(i) + " - " + months[i - 1]);
    }
    return expirationMonths;
}

From source file:com.citrix.cpbm.portal.fragment.controllers.AbstractReportController.java

private void addMonthAndYearToMap(ModelMap modelMap, Locale locale) {
    Calendar cal = Calendar.getInstance();
    String monthsArr[] = new DateFormatSymbols(locale).getMonths();
    List<String> months = new ArrayList<String>();
    for (String mon : monthsArr) {
        if (mon != null && mon.length() > 0) {
            months.add(mon);/*from w ww  .j  ava2 s. com*/
        }
    }
    modelMap.addAttribute("months", months);
    List<String> years = new ArrayList<String>();
    years.add(Integer.toString(cal.get(Calendar.YEAR) - 3));
    years.add(Integer.toString(cal.get(Calendar.YEAR) - 2));
    years.add(Integer.toString(cal.get(Calendar.YEAR) - 1));
    years.add(Integer.toString(cal.get(Calendar.YEAR)));
    modelMap.addAttribute("years", years);
}

From source file:org.apache.click.extras.control.DateField.java

/**
 * Return the names of months and weekdays as a script.
 */// w ww  .j  a  v a 2 s .co  m
protected void addCalenderTranslations(List<Element> headElements) {
    JsScript script = new JsScript();
    script.setId("datefield-js-setup-global");
    if (!headElements.contains(script)) {
        DateFormatSymbols dfs = new DateFormatSymbols(getLocale());

        HtmlStringBuffer buffer = new HtmlStringBuffer(150);
        buffer.append("Date.months=new Array(");
        generateJavaScriptArray(buffer, dfs.getMonths(), 0, 12);
        buffer.append(");\n");

        buffer.append("Date.monthAbbreviations=new Array(");
        generateJavaScriptArray(buffer, dfs.getShortMonths(), 0, 12);
        buffer.append(");\n");

        buffer.append("Date.dayNames=new Array(");
        generateJavaScriptArray(buffer, dfs.getWeekdays(), Calendar.SUNDAY, Calendar.SATURDAY + 1);
        buffer.append(");\n");

        buffer.append("Date.dayAbbreviations=new Array(");
        generateJavaScriptArray(buffer, dfs.getShortWeekdays(), Calendar.SUNDAY, Calendar.SATURDAY + 1);
        buffer.append(");\n");

        String[] weekdays = null;
        if (getMessages().containsKey("calendar-weekdays-heading")) {
            String headings = getMessage("calendar-weekdays-heading");
            weekdays = StringUtils.splitPreserveAllTokens("," + headings, ',');
        } else {
            weekdays = dfs.getShortWeekdays();
        }
        String[] days = new String[7];
        int firstDayOfWeek = getFirstDayOfWeek() - 1;
        for (int i = 0; i < 7; i++) {
            days[i] = weekdays[(i + firstDayOfWeek) % 7 + 1];
        }
        buffer.append("Date.weekdays=new Array(");
        generateJavaScriptArray(buffer, days, 0, 7);
        buffer.append(");\n");

        buffer.append("Date.first_day_of_week=").append(firstDayOfWeek).append(";\n");
        if (getMessages().containsKey("calendar-ok")) {
            buffer.append("_translations[\"OK\"] = \"");
            buffer.append(getMessage("calendar-ok"));
            buffer.append("\";\n");
        }
        if (getMessages().containsKey("calendar-now")) {
            buffer.append("_translations[\"Now\"] = \"");
            buffer.append(getMessage("calendar-now"));
            buffer.append("\";\n");
        }
        if (getMessages().containsKey("calendar-today")) {
            buffer.append("_translations[\"Today\"] = \"");
            buffer.append(getMessage("calendar-today"));
            buffer.append("\";\n");
        }
        if (getMessages().containsKey("calendar-clear")) {
            buffer.append("_translations[\"Clear\"] = \"");
            buffer.append(getMessage("calendar-clear"));
            buffer.append("\";\n");
        }

        script.setContent(buffer.toString());
        headElements.add(script);
    }
}