All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.time4j.SystemFormatEngine Maven / Gradle / Ivy

There is a newer version: 4.38
Show newest version
/*
 * -----------------------------------------------------------------------
 * Copyright © 2013-2015 Meno Hochschild, 
 * -----------------------------------------------------------------------
 * This file (SystemFormatEngine.java) is part of project Time4J.
 *
 * Time4J is free software: You can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation, either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * Time4J is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Time4J. If not, see .
 * -----------------------------------------------------------------------
 */

package net.time4j;

import net.time4j.engine.ChronoEntity;
import net.time4j.format.FormatEngine;
import net.time4j.format.Leniency;
import net.time4j.format.TemporalFormatter;
import net.time4j.scale.UniversalTime;

import java.util.Collections;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;


/**
 * 

The system format engine.

* * @author Meno Hochschild * @since 3.0 */ class SystemFormatEngine implements FormatEngine { //~ Statische Felder/Initialisierungen -------------------------------- static final FormatEngine INSTANCE = new SystemFormatEngine(); static final String RFC_1123_PATTERN = ""; private static final Set> SUPPORTED_TYPES; static { Set> tmp = new HashSet>(); tmp.add(PlainDate.class); tmp.add(PlainTime.class); tmp.add(PlainTimestamp.class); tmp.add(Moment.class); SUPPORTED_TYPES = Collections.unmodifiableSet(tmp); } //~ Konstruktoren ----------------------------------------------------- // Singleton-Konstruktor private SystemFormatEngine() { super(); } //~ Methoden ---------------------------------------------------------- @Override public > TemporalFormatter create( Class chronoType, String formatPattern, Platform patternType, Locale locale ) { if (patternType == null) { throw new NullPointerException("Missing pattern type."); } else if (!this.isSupported(chronoType)) { throw new IllegalArgumentException("Not formattable: " + chronoType); } return new SystemTemporalFormatter( chronoType, formatPattern, locale, Leniency.SMART, null ); } @Override public TemporalFormatter createRFC1123() { return new SystemTemporalFormatter( Moment.class, RFC_1123_PATTERN, Locale.ENGLISH, Leniency.SMART, "GMT" ); } @Override public Platform getDefaultPatternType() { return Platform.PATTERN; } @Override public boolean isSupported(Class chronoType) { return SUPPORTED_TYPES.contains(chronoType); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy