List of usage examples for java.text DateFormatSymbols DateFormatSymbols
private DateFormatSymbols(boolean flag)
From source file:com.redinput.datetimepickercompat.date.DatePickerDialog.java
private void updateDisplay(boolean announce) { if (mDayOfWeekView != null) { mDayOfWeekView.setText(/* w ww . j ava 2 s. c o m*/ new DateFormatSymbols(Locale.getDefault()).getWeekdays()[mCalendar.get(Calendar.DAY_OF_WEEK)] .toUpperCase(Locale.getDefault())); } mSelectedMonthTextView .setText(new DateFormatSymbols(Locale.getDefault()).getMonths()[mCalendar.get(Calendar.MONTH)] .toUpperCase(Locale.getDefault())); mSelectedDayTextView.setText(DAY_FORMAT.format(mCalendar.getTime())); mYearView.setText(YEAR_FORMAT.format(mCalendar.getTime())); // Accessibility. long millis = mCalendar.getTimeInMillis(); mAnimator.setDateMillis(millis); int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NO_YEAR; String monthAndDayText = DateUtils.formatDateTime(getActivity(), millis, flags); mMonthAndDayView.setContentDescription(monthAndDayText); if (announce) { flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR; String fullDateText = DateUtils.formatDateTime(getActivity(), millis, flags); Utils.tryAccessibilityAnnounce(mAnimator, fullDateText); } }
From source file:com.samsistemas.calendarview.widget.CalendarView.java
/** * Initialize the calendar week layout, considers start day *///from ww w.j a va2s .c o m private void initWeekLayout() { TextView dayOfWeek; String dayOfTheWeekString; //Setting background color white View titleLayout = mView.findViewById(R.id.week_layout); titleLayout.setBackgroundColor(mWeekLayoutBackgroundColor); final String[] weekDaysArray = new DateFormatSymbols(getLocale()).getShortWeekdays(); for (int i = 1; i < weekDaysArray.length; i++) { dayOfTheWeekString = weekDaysArray[i]; int length = dayOfTheWeekString.length() < 3 ? dayOfTheWeekString.length() : 3; dayOfTheWeekString = dayOfTheWeekString.substring(0, length).toUpperCase(); dayOfWeek = (TextView) mView.findViewWithTag( mContext.getString(R.string.day_of_week) + CalendarUtility.getWeekIndex(i, mCalendar)); dayOfWeek.setText(dayOfTheWeekString); mIsCommonDay = true; if (totalDayOfWeekend().length != 0) { for (int weekend : totalDayOfWeekend()) { if (i == weekend) { dayOfWeek.setTextColor(mWeekendColor); mIsCommonDay = false; } } } if (mIsCommonDay) { dayOfWeek.setTextColor(mDayOfWeekTextColor); } if (null != getTypeface()) { dayOfWeek.setTypeface(getTypeface()); } } }
From source file:org.pentaho.plugin.jfreereport.reportcharts.BarLineChartExpression.java
protected void configureChart(final JFreeChart chart) { super.configureChart(chart); final CategoryPlot plot = chart.getCategoryPlot(); if (isSharedRangeAxis() == false) { final ValueAxis linesAxis = plot.getRangeAxis(1); if (linesAxis instanceof NumberAxis) { final NumberAxis numberAxis = (NumberAxis) linesAxis; numberAxis.setAutoRangeIncludesZero(isLineAxisIncludesZero()); numberAxis.setAutoRangeStickyZero(isLineAxisStickyZero()); if (getLinePeriodCount() > 0) { if (getLineTicksLabelFormat() != null) { final FastDecimalFormat formatter = new FastDecimalFormat(getLineTicksLabelFormat(), getResourceBundleFactory().getLocale()); numberAxis.setTickUnit(new FastNumberTickUnit(getLinePeriodCount(), formatter)); } else { numberAxis.setTickUnit(new FastNumberTickUnit(getLinePeriodCount())); }//w w w . j a va 2 s . c o m } else { if (getLineTicksLabelFormat() != null) { final DecimalFormat formatter = new DecimalFormat(getLineTicksLabelFormat(), new DecimalFormatSymbols(getResourceBundleFactory().getLocale())); numberAxis.setNumberFormatOverride(formatter); } } } else if (linesAxis instanceof DateAxis) { final DateAxis numberAxis = (DateAxis) linesAxis; if (getLinePeriodCount() > 0 && getLineTimePeriod() != null) { if (getLineTicksLabelFormat() != null) { final SimpleDateFormat formatter = new SimpleDateFormat(getLineTicksLabelFormat(), new DateFormatSymbols(getResourceBundleFactory().getLocale())); numberAxis.setTickUnit(new DateTickUnit(getDateUnitAsInt(getLineTimePeriod()), (int) getLinePeriodCount(), formatter)); } else { numberAxis.setTickUnit(new DateTickUnit(getDateUnitAsInt(getLineTimePeriod()), (int) getLinePeriodCount())); } } else if (getRangeTickFormatString() != null) { final SimpleDateFormat formatter = new SimpleDateFormat(getRangeTickFormatString(), new DateFormatSymbols(getResourceBundleFactory().getLocale())); numberAxis.setDateFormatOverride(formatter); } } if (linesAxis != null) { final Font labelFont = Font.decode(getLabelFont()); linesAxis.setLabelFont(labelFont); linesAxis.setTickLabelFont(labelFont); if (getLineTitleFont() != null) { linesAxis.setLabelFont(getLineTitleFont()); } if (getLineTickFont() != null) { linesAxis.setTickLabelFont(getLineTickFont()); } final int level = getRuntime().getProcessingContext().getCompatibilityLevel(); if (ClassicEngineBoot.isEnforceCompatibilityFor(level, 3, 8)) { if (getRangeMinimum() != 0) { linesAxis.setLowerBound(getLineRangeMinimum()); } if (getRangeMaximum() != 1) { linesAxis.setUpperBound(getLineRangeMaximum()); } if (getLineRangeMinimum() == 0 && getLineRangeMaximum() == 1) { linesAxis.setLowerBound(0); linesAxis.setUpperBound(1); linesAxis.setAutoRange(true); } } else { linesAxis.setLowerBound(getLineRangeMinimum()); linesAxis.setUpperBound(getLineRangeMaximum()); linesAxis.setAutoRange(isLineAxisAutoRange()); } } } final LineAndShapeRenderer linesRenderer = (LineAndShapeRenderer) plot.getRenderer(1); if (linesRenderer != null) { //set stroke with line width linesRenderer.setStroke(translateLineStyle(lineWidth, lineStyle)); //hide shapes on line linesRenderer.setShapesVisible(isMarkersVisible()); linesRenderer.setBaseShapesFilled(isMarkersVisible()); //set colors for each line for (int i = 0; i < lineSeriesColor.size(); i++) { final String s = (String) lineSeriesColor.get(i); linesRenderer.setSeriesPaint(i, parseColorFromString(s)); } } }
From source file:com.concursive.connect.web.modules.calendar.utils.CalendarView.java
/** * Sets the Locale attribute of the CalendarView object * * @param theLocale The new Locale value *///from ww w . j a v a2 s. c om public void setLocale(Locale theLocale) { if (locale == null) { symbols = new DateFormatSymbols(theLocale); monthNames = symbols.getMonths(); shortMonthNames = symbols.getShortMonths(); locale = theLocale; cal = Calendar.getInstance(locale); today = cal.get(Calendar.DAY_OF_MONTH); day = cal.get(Calendar.DAY_OF_MONTH); month = cal.get(Calendar.MONTH); year = cal.get(Calendar.YEAR); calPrev = Calendar.getInstance(locale); calNext = Calendar.getInstance(locale); this.update(); } }
From source file:de.fau.amos.ChartRenderer.java
/** * Creates Chart with TimeLine (JFreeChart object) from TimeSeriesCollection. Is used when granularity is set to hours. * Adjusts display of the chart, not the values itself. * /*www .j a v a2 s . co m*/ * @param collection TimeSeriesCollection that should be used as basis of chart. * @param timeGranularity Selected granularity. Value is similar to granularity contained in TimeSeriesCollection "collection". * @param time first element of time that is displayed. Is used for caption text and axis text. * @param unit Unit of displayed values (kWh or kWh/TNF). * @return Returns finished JFreeChart object. */ private JFreeChart createTimeLineChart(TimeSeriesCollection collection, String timeGranularity, String time, String unit) { // Modification of X-Axis Label int day = Integer.parseInt(time.substring(8, 10)); int month = Integer.parseInt(time.substring(5, 7)); int year = Integer.parseInt(time.substring(0, 4)); //get Weekday Calendar c = Calendar.getInstance(); c.set(year, month - 1, day, 0, 0); int weekDay = c.get(Calendar.DAY_OF_WEEK); String dayString = new DateFormatSymbols(Locale.US).getWeekdays()[weekDay] + ", " + day + ". "; String monthString = new DateFormatSymbols(Locale.US).getMonths()[month - 1]; String xAxisLabel = "" + dayString + monthString + " " + time.substring(0, 4); //Creation of the lineChart JFreeChart lineChart = ChartFactory.createTimeSeriesChart("Line Chart", // title xAxisLabel, // x-axis label // "Energy Consumption "+("1".equals(unit)?"[kWh]":("2".equals(unit)?"[kWh/TNF]":("3".equals(unit)?"[TNF]":""))), // y-axis label ("1".equals(unit) ? "Energy Consumption [kWh]" : ("2".equals(unit) ? "Energy Consumption [kWh/TNF]" : ("3".equals(unit) ? "Produced Pieces [TNF]" : ""))), collection, // data true, // create legend? false, // generate tooltips? false // generate URLs? ); //graphical modifications for LineChart lineChart.setBackgroundPaint(Color.white); XYPlot plot = lineChart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0)); return lineChart; }
From source file:com.redinput.datetimepickercompat.date.SimpleMonthView.java
private void drawMonthDayLabels(Canvas canvas) { int y = MONTH_HEADER_SIZE - (MONTH_DAY_LABEL_TEXT_SIZE / 2); int dayWidthHalf = (mWidth - mPadding * 2) / (mNumDays * 2); for (int i = 0; i < mNumDays; i++) { int calendarDay = (i + mWeekStart) % mNumDays; int x = (2 * i + 1) * dayWidthHalf + mPadding; mDayLabelCalendar.set(Calendar.DAY_OF_WEEK, calendarDay); canvas.drawText(/*w w w . java 2 s . c o m*/ new DateFormatSymbols(Locale.getDefault()).getWeekdays()[mDayLabelCalendar .get(Calendar.DAY_OF_WEEK)].toUpperCase(Locale.getDefault()).substring(0, 3), x, y, mMonthDayLabelPaint); } }
From source file:org.eredlab.g4.ccl.net.ftp.FTPClientConfig.java
/** * Looks up the supplied language code in the internally maintained table of * language codes. Returns a DateFormatSymbols object configured with * short month names corresponding to the code. If there is no corresponding * entry in the table, the object returned will be that for * <code>Locale.US</code> // w ww . java2s .co m * @param languageCode See {@link #setServerLanguageCode(String) serverLanguageCode} * @return a DateFormatSymbols object configured with short month names * corresponding to the supplied code, or with month names for * <code>Locale.US</code> if there is no corresponding entry in the internal * table. */ public static DateFormatSymbols lookupDateFormatSymbols(String languageCode) { Object lang = LANGUAGE_CODE_MAP.get(languageCode); if (lang != null) { if (lang instanceof Locale) { return new DateFormatSymbols((Locale) lang); } else if (lang instanceof String) { return getDateFormatSymbols((String) lang); } } return new DateFormatSymbols(Locale.US); }
From source file:org.eredlab.g4.ccl.net.ftp.FTPClientConfig.java
/** * Returns a DateFormatSymbols object configured with short month names * as in the supplied string//from w w w.j a v a 2 s. c o m * @param shortmonths This should be as described in * {@link #setShortMonthNames(String) shortMonthNames} * @return a DateFormatSymbols object configured with short month names * as in the supplied string */ public static DateFormatSymbols getDateFormatSymbols(String shortmonths) { String[] months = splitShortMonthString(shortmonths); DateFormatSymbols dfs = new DateFormatSymbols(Locale.US); dfs.setShortMonths(months); return dfs; }
From source file:de.fau.amos.ChartRenderer.java
/** * Creates Chart with Bars (JFreeChart object) from TimeSeriesCollection. Is used when granularity is set to days, months or years. * Adjusts display of the chart, not the values itself. * /*w w w . j av a2 s. co m*/ * @param collection TimeSeriesCollection that should be used as basis of chart. * @param timeGranularity Selected granularity. Value is similar to granularity contained in TimeSeriesCollection "collection". * @param time first element of time that is displayed. Is used for caption text and axis text. * @param unit Unit of displayed values (kWh or kWh/TNF). * @return Returns finished JFreeChart object. */ private JFreeChart createTimeBarChart(TimeSeriesCollection collection, String timeGranularity, String time, String unit) { String xAxisLabel = null; // Modification of X-Axis Label (depending on the granularity) int month; String monthString = null; switch (timeGranularity) { //for Case "0" see method "createTimeLineChart" case "1": month = Integer.parseInt(time.substring(5, 7)); monthString = new DateFormatSymbols(Locale.US).getMonths()[month - 1]; xAxisLabel = "" + monthString + " " + time.substring(0, 4); break; case "2": xAxisLabel = time.substring(0, 4); break; case "3": xAxisLabel = "Years"; break; default: xAxisLabel = "Timespan"; } JFreeChart barChart = ChartFactory.createXYBarChart("Bar Chart", // title xAxisLabel, // x-axis label true, // date axis? // "Energy Consumption "+("1".equals(unit)?"[kWh]":("2".equals(unit)?"[kWh/TNF]":("3".equals(unit)?"[TNF]":""))), // y-axis label ("1".equals(unit) ? "Energy Consumption [kWh]" : ("2".equals(unit) ? "Energy Consumption [kWh/TNF]" : ("3".equals(unit) ? "Produced Pieces [TNF]" : ""))), collection, // data PlotOrientation.VERTICAL, // orientation true, // create legend? true, // generate tooltips? false // generate URLs? ); //graphical modifications for BarChart barChart.setBackgroundPaint(Color.white); XYPlot plot = barChart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0)); //Axis modification: Set Axis X-Value directly below the bars DateAxis dateAxis = (DateAxis) plot.getDomainAxis(); dateAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); //Axis modification: Remove Values from x-Axis that belong to former/later time element (Month/Day) dateAxis.setLowerMargin(0.01); dateAxis.setUpperMargin(0.01); //Axis modification: Axis values (depending on timeGranularity) if (timeGranularity.equals("1")) { dateAxis.setTickUnit( new DateTickUnit(DateTickUnitType.DAY, 2, new SimpleDateFormat(" dd. ", Locale.US))); } if (timeGranularity.equals("2")) { dateAxis.setTickUnit( new DateTickUnit(DateTickUnitType.MONTH, 1, new SimpleDateFormat(" MMM ", Locale.US))); } if (timeGranularity.equals("3")) { dateAxis.setTickUnit( new DateTickUnit(DateTickUnitType.YEAR, 1, new SimpleDateFormat(" yyyy ", Locale.US))); } ClusteredXYBarRenderer clusteredxybarrenderer = new ClusteredXYBarRenderer(0.25, false); clusteredxybarrenderer.setShadowVisible(false); clusteredxybarrenderer.setBarPainter(new StandardXYBarPainter()); plot.setRenderer(clusteredxybarrenderer); return barChart; }
From source file:nl.tricode.magnolia.blogs.templates.BlogRenderableDefinition.java
public static String getMonthName(String month) { int monthNr = Integer.parseInt(month); Locale locale = new Locale(DEFAULT_LANGUAGE); DateFormatSymbols symbols = new DateFormatSymbols(locale); String[] monthNames = symbols.getMonths(); return monthNames[monthNr - 1]; }