Example usage for java.text DateFormatSymbols setShortMonths

List of usage examples for java.text DateFormatSymbols setShortMonths

Introduction

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

Prototype

public void setShortMonths(String[] newShortMonths) 

Source Link

Document

Sets short month strings.

Usage

From source file:Main.java

public static void main(String[] args) {
    String[] newMonths = { "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" };
    String[] newShortMonths = { "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov",
            "dec" };
    String[] newWeekdays = { "", "Monday", "Tuesday", "Webnesday", "Thursday", "Friday", "Saturaday",
            "Sunday" };
    String[] shortWeekdays = { "", "monday", "tuesday", "webnesday", "thursday", "friday", "saturaday",
            "sunday" };

    DateFormatSymbols symbols = new DateFormatSymbols();
    symbols.setMonths(newMonths);/*from w  ww  .  jav a  2  s . c o m*/
    symbols.setShortMonths(newShortMonths);
    symbols.setWeekdays(newWeekdays);
    symbols.setShortWeekdays(shortWeekdays);

    DateFormat format = new SimpleDateFormat("dd MMMM yyyy", symbols);
    System.out.println(format.format(new Date()));

    format = new SimpleDateFormat("dd MMM yyyy", symbols);
    System.out.println(format.format(new Date()));

    format = new SimpleDateFormat("EEEE, dd MMM yyyy", symbols);
    System.out.println(format.format(new Date()));

    format = new SimpleDateFormat("E, dd MMM yyyy", symbols);
    System.out.println(format.format(new Date()));
}

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/*  www .  j  a v a2 s .c om*/
 * @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: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   w  ww. j  a v  a  2 s .  co m
    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:nya.miku.wishmaster.chans.nullchancc.NullchanccModule.java

@SuppressLint("SimpleDateFormat")
@Override//from  w ww .ja va2 s . c o m
protected WakabaReader getWakabaReader(InputStream stream, UrlPageModel urlModel) {
    if (urlModel != null && urlModel.chanName != null && urlModel.chanName.equals("expand")) {
        stream = new SequenceInputStream(new ByteArrayInputStream("<form id=\"delform\">".getBytes()), stream);
    }
    return new WakabaReader(stream) {
        private final DateFormat dateFormat;
        {
            DateFormatSymbols symbols = new DateFormatSymbols();
            symbols.setShortMonths(new String[] { "", "", "", "?", "", "",
                    "", "?", "", "", "??", "" });
            dateFormat = new SimpleDateFormat("yyyy MMM dd HH:mm:ss", symbols);
            dateFormat.setTimeZone(TimeZone.getTimeZone("GMT+3"));
        }

        @Override
        protected void parseDate(String date) {
            if (date.length() > 0) {
                date = date.replaceAll("(?:[^\\d]*)(\\d(?:.*))", "$1");
                try {
                    currentPost.timestamp = dateFormat.parse(date).getTime();
                } catch (Exception e) {
                    Logger.e(TAG, "cannot parse date", e);
                }
            }
        }

        @Override
        protected void parseOmittedString(String omitted) {
            if (omitted.indexOf('>') != -1)
                omitted = omitted.substring(omitted.indexOf('>'));
            super.parseOmittedString(omitted);
        }

        @Override
        protected void postprocessPost(PostModel post) {
            Matcher matcher = PATTERN_EMBEDDED.matcher(post.comment);
            while (matcher.find()) {
                String id = matcher.group(1);
                String div = matcher.group(0).toLowerCase(Locale.US);
                String url = null;
                if (div.contains("youtube")) {
                    url = "http://www.youtube.com/watch?v=" + id;
                } else if (div.contains("vimeo")) {
                    url = "http://vimeo.com/" + id;
                } else if (div.contains("coub")) {
                    url = "http://coub.com/view/" + id;
                }
                if (url != null) {
                    AttachmentModel attachment = new AttachmentModel();
                    attachment.type = AttachmentModel.TYPE_OTHER_NOTFILE;
                    attachment.path = url;
                    attachment.thumbnail = div.contains("youtube")
                            ? ("http://img.youtube.com/vi/" + id + "/default.jpg")
                            : null;
                    int oldCount = post.attachments != null ? post.attachments.length : 0;
                    AttachmentModel[] attachments = new AttachmentModel[oldCount + 1];
                    for (int i = 0; i < oldCount; ++i)
                        attachments[i] = post.attachments[i];
                    attachments[oldCount] = attachment;
                    post.attachments = attachments;
                }
            }
        }
    };
}