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

net.time4j.format.DisplayMode Maven / Gradle / Ivy

There is a newer version: 4.38
Show newest version
/*
 * -----------------------------------------------------------------------
 * Copyright © 2013-2015 Meno Hochschild, 
 * -----------------------------------------------------------------------
 * This file (DisplayMode.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.format;

import net.time4j.engine.DisplayStyle;

import java.text.DateFormat;


/**
 * 

Defines how many details will be displayed in chronological texts.

* * @author Meno Hochschild */ /*[deutsch] *

Definiert Anzeigestile, wie detailliert chronologische Informationen * dargestellt werden.

* * @author Meno Hochschild */ public enum DisplayMode implements DisplayStyle { //~ Statische Felder/Initialisierungen -------------------------------- /** Full display with maximum detailed content. */ /*[deutsch] Volle Anzeige mit maximalem Detailgehalt. */ FULL(DateFormat.FULL), /** Verbose display with many details. */ /*[deutsch] Gesprächige Anzeige mit vielen Details. */ LONG(DateFormat.LONG), /** Normal display with few details. */ /*[deutsch] Normale Anzeige mit wenigen Details. */ MEDIUM(DateFormat.MEDIUM), /** Shortened display, typically in numerical form. */ /*[deutsch] Verkürzte Anzeige, typischerweise numerisch. */ SHORT(DateFormat.SHORT); private static DisplayMode[] ENUMS = DisplayMode.values(); //~ Instanzvariablen -------------------------------------------------- private transient final int style; //~ Konstruktoren ----------------------------------------------------- private DisplayMode(int style) { this.style = style; } //~ Methoden ---------------------------------------------------------- @Override public int getStyleValue() { return this.style; } /** *

Converts a {@code DateFormat}-constant.

* * @param style traditional format style * @return associated DisplayMode * @throws UnsupportedOperationException if given style is not supported * @see java.text.DateFormat#FULL * @see java.text.DateFormat#LONG * @see java.text.DateFormat#MEDIUM * @see java.text.DateFormat#SHORT * @since 3.10/4.7 */ /*[deutsch] *

Konvertiert eine {@code DateFormat}-Konstante.

* * @param style traditional format style * @return associated DisplayMode * @throws UnsupportedOperationException if given style is not supported * @see java.text.DateFormat#FULL * @see java.text.DateFormat#LONG * @see java.text.DateFormat#MEDIUM * @see java.text.DateFormat#SHORT * @since 3.10/4.7 */ public static DisplayMode ofStyle(int style) { for (DisplayMode mode : ENUMS) { if (mode.getStyleValue() == style) { return mode; } } throw new UnsupportedOperationException("Unknown format style: " + style); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy