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

The following examples show how to use java.text.DateFormat#clone() . 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 check out the related API usage on the sidebar.
Example 1
Source File: SerializerProvider.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
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 2
Source File: PeriodAxisLabelInfo.java    From buffer_bci with GNU General Public License v3.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 3
Source File: PeriodAxisLabelInfo.java    From ccu-historian with GNU General Public License v3.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 4
Source File: PeriodAxisLabelInfo.java    From SIMVA-SoS with 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
Source File: PeriodAxisLabelInfo.java    From buffer_bci with GNU General Public License v3.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 6
Source File: PeriodAxisLabelInfo.java    From ECG-Viewer with GNU General Public License v2.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 7
Source File: PeriodAxisLabelInfo.java    From openstock with GNU General Public License v3.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 8
Source File: TimeSeriesURLGenerator.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 9
Source File: TimeSeriesURLGenerator.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 10
Source File: TimeSeriesURLGenerator.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
Source File: TimeSeriesURLGenerator.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 12
Source File: TimeSeriesURLGenerator.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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
Source File: DateFormatWrapper.java    From super-csv-annotation with Apache License 2.0 5 votes vote down vote up
/**
 * フォーマッタを指定してインスタンスを作成するコンストラクタ。
 * @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 14
Source File: DateFormatTest.java    From j2objc with 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 15
Source File: TimeSeriesURLGenerator.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * 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 16
Source File: TimeSeriesURLGenerator.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 17
Source File: DeserializationContext.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
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 18
Source File: TimeSeriesURLGenerator.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}