Example usage for java.text DateFormat getDateInstance

List of usage examples for java.text DateFormat getDateInstance

Introduction

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

Prototype

public static final DateFormat getDateInstance() 

Source Link

Document

Gets the date formatter with the default formatting style for the default java.util.Locale.Category#FORMAT FORMAT locale.

Usage

From source file:edu.ucla.stat.SOCR.chart.ChartGenerator_JTable.java

private JFreeChart createCategoryEventFreqChart_Time(String title, String xLabel, String yLabel,
        CategoryDataset dataset) {//from  w w w  .  j  a va2s  .c  o m

    JFreeChart chart = ChartFactory.createBarChart(title, // title
            xLabel, // domain axis label
            yLabel, // range axis label
            dataset, // dataset
            orientation, // orientation
            true, // include legend
            true, // tooltips
            false // URLs
    );

    chart.setBackgroundPaint(new Color(0xFF, 0xFF, 0xCC));

    // get a reference to the plot for further customisation...
    CategoryPlot plot = chart.getCategoryPlot();
    plot.getDomainAxis().setMaximumCategoryLabelWidthRatio(10.0f);
    plot.setRangeAxis(new DateAxis(yLabel));
    CategoryToolTipGenerator toolTipGenerator = new StandardCategoryToolTipGenerator("",
            DateFormat.getDateInstance());
    LineAndShapeRenderer renderer = new LineAndShapeRenderer(false, true);
    renderer.setBaseToolTipGenerator(toolTipGenerator);
    plot.setRenderer(renderer);

    // setCategorySummary(dataset); time
    return chart;
}

From source file:edu.ucla.stat.SOCR.chart.ChartGenerator_JTable.java

/**
 *
 *//* ww w  . j  a va  2s.  c  o m*/
private void setDateAxis(XYPlot plot) {
    XYItemRenderer renderer = plot.getRenderer();
    StandardXYToolTipGenerator generator;
    if (timeType.equalsIgnoreCase("Year"))
        generator = new StandardXYToolTipGenerator("{1} = {2}", new SimpleDateFormat("yyyy"),
                new DecimalFormat("0"));
    else if (timeType.equalsIgnoreCase("Day"))
        generator = new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
                new SimpleDateFormat("d-MMM-yy"), new DecimalFormat("#,##0.00"));
    else if (timeType.equalsIgnoreCase("Month"))
        generator = new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
                new SimpleDateFormat("MM-yy"), new DecimalFormat("#,##0.00"));
    else
        generator = new StandardXYToolTipGenerator("", DateFormat.getDateInstance(),
                new DecimalFormat("#,##0.00"));

    renderer.setBaseToolTipGenerator(generator);

    DateAxis domainAxis = new DateAxis("Time");
    domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    plot.setDomainAxis(domainAxis);
    //plot.setForegroundAlpha(0.5f);
}

From source file:com.actelion.research.table.view.JVisualization.java

protected String createDateLabel(int theMarker, int exponent) {
    long time = theMarker;
    while (exponent < 0) {
        if (time % 10 != 0)
            return null;
        time /= 10;//from   www.ja v  a  2 s .  c o  m
        exponent++;
    }
    while (exponent > 0) {
        time *= 10;
        exponent--;
    }
    return DateFormat.getDateInstance().format(new Date(86400000 * time + 43200000));
}

From source file:au.org.theark.core.dao.StudyDao.java

private boolean validDateFormat(String value) {
    String[] formatStrings = { Constants.DD_MM_YYYY };
    boolean isInvalidFormat = false;

    for (String formatString : formatStrings) {
        try {/*  w  ww .  j av  a2s .  co m*/
            SimpleDateFormat sdf = (SimpleDateFormat) DateFormat.getDateInstance();
            sdf.applyPattern(formatString);
            sdf.setLenient(false);
            sdf.parse(value);

            if (sdf.format(sdf.parse(value)).equals(value) && value.length() == sdf.toPattern().length()) {
                isInvalidFormat = true;
            }
        } catch (ParseException e) {
            isInvalidFormat = false;
        }
    }
    return isInvalidFormat;
}