Java Code Examples for java.text.DateFormat#clone()

The following examples show how to use java.text.DateFormat#clone() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
/**
 * Creates a new instance.
 *
 * @param periodClass  the subclass of {@link RegularTimePeriod} to use
 *                     (<code>null</code> not permitted).
 * @param dateFormat  the date format (<code>null</code> not permitted).
 * @param padding  controls the space around the band (<code>null</code>
 *                 not permitted).
 * @param labelFont  the label font (<code>null</code> not permitted).
 * @param labelPaint  the label paint (<code>null</code> not permitted).
 * @param drawDividers  a flag that controls whether dividers are drawn.
 * @param dividerStroke  the stroke used to draw the dividers
 *                       (<code>null</code> not permitted).
 * @param dividerPaint  the paint used to draw the dividers
 *                      (<code>null</code> not permitted).
 */
public PeriodAxisLabelInfo(Class periodClass, DateFormat dateFormat,
        RectangleInsets padding, Font labelFont, Paint labelPaint,
        boolean drawDividers, Stroke dividerStroke, Paint dividerPaint) {
    ParamChecks.nullNotPermitted(periodClass, "periodClass");
    ParamChecks.nullNotPermitted(dateFormat, "dateFormat");
    ParamChecks.nullNotPermitted(padding, "padding");
    ParamChecks.nullNotPermitted(labelFont, "labelFont");
    ParamChecks.nullNotPermitted(labelPaint, "labelPaint");
    ParamChecks.nullNotPermitted(dividerStroke, "dividerStroke");
    ParamChecks.nullNotPermitted(dividerPaint, "dividerPaint");
    this.periodClass = periodClass;
    this.dateFormat = (DateFormat) dateFormat.clone();
    this.padding = padding;
    this.labelFont = labelFont;
    this.labelPaint = labelPaint;
    this.drawDividers = drawDividers;
    this.dividerStroke = dividerStroke;
    this.dividerPaint = dividerPaint;
}
 
Example 2
protected final DateFormat _dateFormat()
{
    if (_dateFormat != null) {
        return _dateFormat;
    }
    /* At this point, all timezone configuration should have occurred, with respect
     * to default dateformat configuration. But we still better clone
     * an instance as formatters are stateful, not thread-safe.
     */
    DateFormat df = _config.getDateFormat();
    _dateFormat = df = (DateFormat) df.clone();
    // [databind#939]: 26-Sep-2015, tatu: With 2.6, formatter has been (pre)configured
    // with TimeZone, so we should NOT try overriding it unlike with earlier versions
    /*
    TimeZone tz = getTimeZone();
    if (tz != df.getTimeZone()) {
        df.setTimeZone(tz);
    }
    */
    return df;
}
 
Example 3
/**
 * Creates a new instance.
 *
 * @param periodClass  the subclass of {@link RegularTimePeriod} to use
 *                     (<code>null</code> not permitted).
 * @param dateFormat  the date format (<code>null</code> not permitted).
 * @param padding  controls the space around the band (<code>null</code>
 *                 not permitted).
 * @param labelFont  the label font (<code>null</code> not permitted).
 * @param labelPaint  the label paint (<code>null</code> not permitted).
 * @param drawDividers  a flag that controls whether dividers are drawn.
 * @param dividerStroke  the stroke used to draw the dividers
 *                       (<code>null</code> not permitted).
 * @param dividerPaint  the paint used to draw the dividers
 *                      (<code>null</code> not permitted).
 */
public PeriodAxisLabelInfo(Class periodClass, DateFormat dateFormat,
        RectangleInsets padding, Font labelFont, Paint labelPaint,
        boolean drawDividers, Stroke dividerStroke, Paint dividerPaint) {
    ParamChecks.nullNotPermitted(periodClass, "periodClass");
    ParamChecks.nullNotPermitted(dateFormat, "dateFormat");
    ParamChecks.nullNotPermitted(padding, "padding");
    ParamChecks.nullNotPermitted(labelFont, "labelFont");
    ParamChecks.nullNotPermitted(labelPaint, "labelPaint");
    ParamChecks.nullNotPermitted(dividerStroke, "dividerStroke");
    ParamChecks.nullNotPermitted(dividerPaint, "dividerPaint");
    this.periodClass = periodClass;
    this.dateFormat = (DateFormat) dateFormat.clone();
    this.padding = padding;
    this.labelFont = labelFont;
    this.labelPaint = labelPaint;
    this.drawDividers = drawDividers;
    this.dividerStroke = dividerStroke;
    this.dividerPaint = dividerPaint;
}
 
Example 4
Source Project: SIMVA-SoS   File: PeriodAxisLabelInfo.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new instance.
 *
 * @param periodClass  the subclass of {@link RegularTimePeriod} to use
 *                     (<code>null</code> not permitted).
 * @param dateFormat  the date format (<code>null</code> not permitted).
 * @param padding  controls the space around the band (<code>null</code>
 *                 not permitted).
 * @param labelFont  the label font (<code>null</code> not permitted).
 * @param labelPaint  the label paint (<code>null</code> not permitted).
 * @param drawDividers  a flag that controls whether dividers are drawn.
 * @param dividerStroke  the stroke used to draw the dividers
 *                       (<code>null</code> not permitted).
 * @param dividerPaint  the paint used to draw the dividers
 *                      (<code>null</code> not permitted).
 */
public PeriodAxisLabelInfo(Class periodClass, DateFormat dateFormat,
        RectangleInsets padding, Font labelFont, Paint labelPaint,
        boolean drawDividers, Stroke dividerStroke, Paint dividerPaint) {
    ParamChecks.nullNotPermitted(periodClass, "periodClass");
    ParamChecks.nullNotPermitted(dateFormat, "dateFormat");
    ParamChecks.nullNotPermitted(padding, "padding");
    ParamChecks.nullNotPermitted(labelFont, "labelFont");
    ParamChecks.nullNotPermitted(labelPaint, "labelPaint");
    ParamChecks.nullNotPermitted(dividerStroke, "dividerStroke");
    ParamChecks.nullNotPermitted(dividerPaint, "dividerPaint");
    this.periodClass = periodClass;
    this.dateFormat = (DateFormat) dateFormat.clone();
    this.padding = padding;
    this.labelFont = labelFont;
    this.labelPaint = labelPaint;
    this.drawDividers = drawDividers;
    this.dividerStroke = dividerStroke;
    this.dividerPaint = dividerPaint;
}
 
Example 5
/**
 * Creates a new instance.
 *
 * @param periodClass  the subclass of {@link RegularTimePeriod} to use
 *                     (<code>null</code> not permitted).
 * @param dateFormat  the date format (<code>null</code> not permitted).
 * @param padding  controls the space around the band (<code>null</code>
 *                 not permitted).
 * @param labelFont  the label font (<code>null</code> not permitted).
 * @param labelPaint  the label paint (<code>null</code> not permitted).
 * @param drawDividers  a flag that controls whether dividers are drawn.
 * @param dividerStroke  the stroke used to draw the dividers
 *                       (<code>null</code> not permitted).
 * @param dividerPaint  the paint used to draw the dividers
 *                      (<code>null</code> not permitted).
 */
public PeriodAxisLabelInfo(Class periodClass, DateFormat dateFormat,
        RectangleInsets padding, Font labelFont, Paint labelPaint,
        boolean drawDividers, Stroke dividerStroke, Paint dividerPaint) {
    ParamChecks.nullNotPermitted(periodClass, "periodClass");
    ParamChecks.nullNotPermitted(dateFormat, "dateFormat");
    ParamChecks.nullNotPermitted(padding, "padding");
    ParamChecks.nullNotPermitted(labelFont, "labelFont");
    ParamChecks.nullNotPermitted(labelPaint, "labelPaint");
    ParamChecks.nullNotPermitted(dividerStroke, "dividerStroke");
    ParamChecks.nullNotPermitted(dividerPaint, "dividerPaint");
    this.periodClass = periodClass;
    this.dateFormat = (DateFormat) dateFormat.clone();
    this.padding = padding;
    this.labelFont = labelFont;
    this.labelPaint = labelPaint;
    this.drawDividers = drawDividers;
    this.dividerStroke = dividerStroke;
    this.dividerPaint = dividerPaint;
}
 
Example 6
/**
 * Construct TimeSeriesURLGenerator overriding defaults.
 *
 * @param dateFormat  a formatter for the date (<code>null</code> not
 *         permitted).
 * @param prefix  the prefix of the URL (<code>null</code> not permitted).
 * @param seriesParameterName  the name of the series parameter in the URL
 *         (<code>null</code> not permitted).
 * @param itemParameterName  the name of the item parameter in the URL
 *         (<code>null</code> not permitted).
 */
public TimeSeriesURLGenerator(DateFormat dateFormat, String prefix,
        String seriesParameterName, String itemParameterName) {

    if (dateFormat == null) {
        throw new IllegalArgumentException("Null 'dateFormat' argument.");
    }
    if (prefix == null) {
        throw new IllegalArgumentException("Null 'prefix' argument.");
    }
    if (seriesParameterName == null) {
        throw new IllegalArgumentException(
                "Null 'seriesParameterName' argument.");
    }
    if (itemParameterName == null) {
        throw new IllegalArgumentException(
                "Null 'itemParameterName' argument.");
    }

    this.dateFormat = (DateFormat) dateFormat.clone();
    this.prefix = prefix;
    this.seriesParameterName = seriesParameterName;
    this.itemParameterName = itemParameterName;

}
 
Example 7
/**
 * Construct TimeSeriesURLGenerator overriding defaults.
 *
 * @param dateFormat  a formatter for the date (<code>null</code> not 
 *         permitted).
 * @param prefix  the prefix of the URL (<code>null</code> not permitted).
 * @param seriesParameterName  the name of the series parameter in the URL
 *         (<code>null</code> not permitted).
 * @param itemParameterName  the name of the item parameter in the URL 
 *         (<code>null</code> not permitted).
 */
public TimeSeriesURLGenerator(DateFormat dateFormat, String prefix,
        String seriesParameterName, String itemParameterName) {

    if (dateFormat == null) {
        throw new IllegalArgumentException("Null 'dateFormat' argument.");
    }
    if (prefix == null) {
        throw new IllegalArgumentException("Null 'prefix' argument.");
    }
    if (seriesParameterName == null) {
        throw new IllegalArgumentException(
                "Null 'seriesParameterName' argument.");
    }
    if (itemParameterName == null) {
        throw new IllegalArgumentException(
                "Null 'itemParameterName' argument.");
    }
    
    this.dateFormat = (DateFormat) dateFormat.clone();
    this.prefix = prefix;
    this.seriesParameterName = seriesParameterName;
    this.itemParameterName = itemParameterName;

}
 
Example 8
/**
 * Creates a new instance.
 *
 * @param periodClass  the subclass of {@link RegularTimePeriod} to use
 *                     (<code>null</code> not permitted).
 * @param dateFormat  the date format (<code>null</code> not permitted).
 * @param padding  controls the space around the band (<code>null</code>
 *                 not permitted).
 * @param labelFont  the label font (<code>null</code> not permitted).
 * @param labelPaint  the label paint (<code>null</code> not permitted).
 * @param drawDividers  a flag that controls whether dividers are drawn.
 * @param dividerStroke  the stroke used to draw the dividers
 *                       (<code>null</code> not permitted).
 * @param dividerPaint  the paint used to draw the dividers
 *                      (<code>null</code> not permitted).
 */
public PeriodAxisLabelInfo(Class periodClass, DateFormat dateFormat,
        RectangleInsets padding, Font labelFont, Paint labelPaint,
        boolean drawDividers, Stroke dividerStroke, Paint dividerPaint) {
    ParamChecks.nullNotPermitted(periodClass, "periodClass");
    ParamChecks.nullNotPermitted(dateFormat, "dateFormat");
    ParamChecks.nullNotPermitted(padding, "padding");
    ParamChecks.nullNotPermitted(labelFont, "labelFont");
    ParamChecks.nullNotPermitted(labelPaint, "labelPaint");
    ParamChecks.nullNotPermitted(dividerStroke, "dividerStroke");
    ParamChecks.nullNotPermitted(dividerPaint, "dividerPaint");
    this.periodClass = periodClass;
    this.dateFormat = (DateFormat) dateFormat.clone();
    this.padding = padding;
    this.labelFont = labelFont;
    this.labelPaint = labelPaint;
    this.drawDividers = drawDividers;
    this.dividerStroke = dividerStroke;
    this.dividerPaint = dividerPaint;
}
 
Example 9
/**
 * Creates a new instance.
 *
 * @param periodClass  the subclass of {@link RegularTimePeriod} to use
 *                     (<code>null</code> not permitted).
 * @param dateFormat  the date format (<code>null</code> not permitted).
 * @param padding  controls the space around the band (<code>null</code>
 *                 not permitted).
 * @param labelFont  the label font (<code>null</code> not permitted).
 * @param labelPaint  the label paint (<code>null</code> not permitted).
 * @param drawDividers  a flag that controls whether dividers are drawn.
 * @param dividerStroke  the stroke used to draw the dividers
 *                       (<code>null</code> not permitted).
 * @param dividerPaint  the paint used to draw the dividers
 *                      (<code>null</code> not permitted).
 */
public PeriodAxisLabelInfo(Class periodClass, DateFormat dateFormat,
        RectangleInsets padding, Font labelFont, Paint labelPaint,
        boolean drawDividers, Stroke dividerStroke, Paint dividerPaint) {
    ParamChecks.nullNotPermitted(periodClass, "periodClass");
    ParamChecks.nullNotPermitted(dateFormat, "dateFormat");
    ParamChecks.nullNotPermitted(padding, "padding");
    ParamChecks.nullNotPermitted(labelFont, "labelFont");
    ParamChecks.nullNotPermitted(labelPaint, "labelPaint");
    ParamChecks.nullNotPermitted(dividerStroke, "dividerStroke");
    ParamChecks.nullNotPermitted(dividerPaint, "dividerPaint");
    this.periodClass = periodClass;
    this.dateFormat = (DateFormat) dateFormat.clone();
    this.padding = padding;
    this.labelFont = labelFont;
    this.labelPaint = labelPaint;
    this.drawDividers = drawDividers;
    this.dividerStroke = dividerStroke;
    this.dividerPaint = dividerPaint;
}
 
Example 10
/**
 * Construct TimeSeriesURLGenerator overriding defaults.
 *
 * @param dateFormat  a formatter for the date (<code>null</code> not
 *         permitted).
 * @param prefix  the prefix of the URL (<code>null</code> not permitted).
 * @param seriesParameterName  the name of the series parameter in the URL
 *         (<code>null</code> not permitted).
 * @param itemParameterName  the name of the item parameter in the URL
 *         (<code>null</code> not permitted).
 */
public TimeSeriesURLGenerator(DateFormat dateFormat, String prefix,
        String seriesParameterName, String itemParameterName) {

    ParamChecks.nullNotPermitted(dateFormat, "dateFormat");
    ParamChecks.nullNotPermitted(prefix, "prefix");
    ParamChecks.nullNotPermitted(seriesParameterName, "seriesParameterName");
    ParamChecks.nullNotPermitted(itemParameterName, "itemParameterName");
    this.dateFormat = (DateFormat) dateFormat.clone();
    this.prefix = prefix;
    this.seriesParameterName = seriesParameterName;
    this.itemParameterName = itemParameterName;
}
 
Example 11
protected DateFormat getDateFormat()
{
    if (_dateFormat != null) {
        return _dateFormat;
    }
    /* 24-Feb-2012, tatu: At this point, all timezone configuration
     *    should have occurred, with respect to default dateformat
     *    and timezone configuration. But we still better clone
     *    an instance as formatters may be stateful.
     */
    DateFormat df = _config.getDateFormat();
    _dateFormat = df = (DateFormat) df.clone();
    return df;
}
 
Example 12
/**
 * Construct TimeSeriesURLGenerator overriding defaults.
 *
 * @param dateFormat  a formatter for the date (<code>null</code> not
 *         permitted).
 * @param prefix  the prefix of the URL (<code>null</code> not permitted).
 * @param seriesParameterName  the name of the series parameter in the URL
 *         (<code>null</code> not permitted).
 * @param itemParameterName  the name of the item parameter in the URL
 *         (<code>null</code> not permitted).
 */
public TimeSeriesURLGenerator(DateFormat dateFormat, String prefix,
        String seriesParameterName, String itemParameterName) {

    ParamChecks.nullNotPermitted(dateFormat, "dateFormat");
    ParamChecks.nullNotPermitted(prefix, "prefix");
    ParamChecks.nullNotPermitted(seriesParameterName, "seriesParameterName");
    ParamChecks.nullNotPermitted(itemParameterName, "itemParameterName");
    this.dateFormat = (DateFormat) dateFormat.clone();
    this.prefix = prefix;
    this.seriesParameterName = seriesParameterName;
    this.itemParameterName = itemParameterName;
}
 
Example 13
/**
 * Construct TimeSeriesURLGenerator overriding defaults.
 *
 * @param dateFormat  a formatter for the date (<code>null</code> not
 *         permitted).
 * @param prefix  the prefix of the URL (<code>null</code> not permitted).
 * @param seriesParameterName  the name of the series parameter in the URL
 *         (<code>null</code> not permitted).
 * @param itemParameterName  the name of the item parameter in the URL
 *         (<code>null</code> not permitted).
 */
public TimeSeriesURLGenerator(DateFormat dateFormat, String prefix,
        String seriesParameterName, String itemParameterName) {

    ParamChecks.nullNotPermitted(dateFormat, "dateFormat");
    ParamChecks.nullNotPermitted(prefix, "prefix");
    ParamChecks.nullNotPermitted(seriesParameterName, "seriesParameterName");
    ParamChecks.nullNotPermitted(itemParameterName, "itemParameterName");
    this.dateFormat = (DateFormat) dateFormat.clone();
    this.prefix = prefix;
    this.seriesParameterName = seriesParameterName;
    this.itemParameterName = itemParameterName;
}
 
Example 14
/**
 * Construct TimeSeriesURLGenerator overriding defaults.
 *
 * @param dateFormat  a formatter for the date (<code>null</code> not
 *         permitted).
 * @param prefix  the prefix of the URL (<code>null</code> not permitted).
 * @param seriesParameterName  the name of the series parameter in the URL
 *         (<code>null</code> not permitted).
 * @param itemParameterName  the name of the item parameter in the URL
 *         (<code>null</code> not permitted).
 */
public TimeSeriesURLGenerator(DateFormat dateFormat, String prefix,
        String seriesParameterName, String itemParameterName) {

    ParamChecks.nullNotPermitted(dateFormat, "dateFormat");
    ParamChecks.nullNotPermitted(prefix, "prefix");
    ParamChecks.nullNotPermitted(seriesParameterName, "seriesParameterName");
    ParamChecks.nullNotPermitted(itemParameterName, "itemParameterName");
    this.dateFormat = (DateFormat) dateFormat.clone();
    this.prefix = prefix;
    this.seriesParameterName = seriesParameterName;
    this.itemParameterName = itemParameterName;
}
 
Example 15
Source Project: j2objc   File: DateFormatTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @tests java.text.DateFormat#clone()
 */
public void test_clone() {
	DateFormat format = DateFormat.getInstance();
	DateFormat clone = (DateFormat) format.clone();
	assertTrue("Clone not equal", format.equals(clone));
	clone.getNumberFormat().setMinimumFractionDigits(123);
	assertTrue("Clone shares NumberFormat", !format.equals(clone));
}
 
Example 16
/**
 * フォーマッタを指定してインスタンスを作成するコンストラクタ。
 * @param formatter 日時のフォーマッタ。
 * @param type 対応する日時のクラス。
 * @throws NullPointerException if formatter is null.
 */
public DateFormatWrapper(final DateFormat formatter, final Class<T> type) {
    Objects.requireNonNull(formatter);
    Objects.requireNonNull(type);
    
    this.formatter = (DateFormat) formatter.clone();
    this.type = type;
    
}
 
Example 17
/**
 * Construct TimeSeriesURLGenerator overriding defaults.
 *
 * @param dateFormat  a formatter for the date (<code>null</code> not
 *         permitted).
 * @param prefix  the prefix of the URL (<code>null</code> not permitted).
 * @param seriesParameterName  the name of the series parameter in the URL
 *         (<code>null</code> not permitted).
 * @param itemParameterName  the name of the item parameter in the URL
 *         (<code>null</code> not permitted).
 */
public TimeSeriesURLGenerator(DateFormat dateFormat, String prefix,
        String seriesParameterName, String itemParameterName) {

    ParamChecks.nullNotPermitted(dateFormat, "dateFormat");
    ParamChecks.nullNotPermitted(prefix, "prefix");
    ParamChecks.nullNotPermitted(seriesParameterName, "seriesParameterName");
    ParamChecks.nullNotPermitted(itemParameterName, "itemParameterName");
    this.dateFormat = (DateFormat) dateFormat.clone();
    this.prefix = prefix;
    this.seriesParameterName = seriesParameterName;
    this.itemParameterName = itemParameterName;
}
 
Example 18
/**
 * Construct TimeSeriesURLGenerator overriding defaults.
 *
 * @param dateFormat  a formatter for the date (<code>null</code> not
 *         permitted).
 * @param prefix  the prefix of the URL (<code>null</code> not permitted).
 * @param seriesParameterName  the name of the series parameter in the URL
 *         (<code>null</code> not permitted).
 * @param itemParameterName  the name of the item parameter in the URL
 *         (<code>null</code> not permitted).
 */
public TimeSeriesURLGenerator(DateFormat dateFormat, String prefix,
        String seriesParameterName, String itemParameterName) {

    ParamChecks.nullNotPermitted(dateFormat, "dateFormat");
    ParamChecks.nullNotPermitted(prefix, "prefix");
    ParamChecks.nullNotPermitted(seriesParameterName, "seriesParameterName");
    ParamChecks.nullNotPermitted(itemParameterName, "itemParameterName");
    this.dateFormat = (DateFormat) dateFormat.clone();
    this.prefix = prefix;
    this.seriesParameterName = seriesParameterName;
    this.itemParameterName = itemParameterName;
}