
org.nuiton.util.MonthEnum Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nuiton-utils Show documentation
Show all versions of nuiton-utils Show documentation
Library of usefull class to be used in any project.
/*
* #%L
* Nuiton Utils
*
* $Id: MonthEnum.java 2360 2012-06-11 10:24:36Z tchemit $
* $HeadURL: http://svn.nuiton.org/svn/nuiton-utils/tags/nuiton-utils-2.6.10/nuiton-utils/src/main/java/org/nuiton/util/MonthEnum.java $
* %%
* Copyright (C) 2004 - 2010 CodeLutin
* %%
* This program 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 3 of the
* License, or (at your option) any later version.
*
* This program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* .
* #L%
*/
package org.nuiton.util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import static org.nuiton.i18n.I18n._;
/**
* Une énumération pour représenter les mois d'une année.
*
* @author tchemit
*/
public enum MonthEnum {
JANUARY(_("nuitonutil.month.january")),
FEBRUARY(_("nuitonutil.month.february")),
MARCH(_("nuitonutil.month.march")),
APRIL(_("nuitonutil.month.april")),
MAY(_("nuitonutil.month.may")),
JUNE(_("nuitonutil.month.june")),
JULY(_("nuitonutil.month.july")),
AUGUST(_("nuitonutil.month.august")),
SEPTEMBER(_("nuitonutil.month.september")),
OCTOBER(_("nuitonutil.month.october")),
NOVEMBER(_("nuitonutil.month.november")),
DECEMBER(_("nuitonutil.month.december"));
/** Logger */
private static final Log log = LogFactory.getLog(MonthEnum.class);
private final String libelle;
MonthEnum(String libelle) {
this.libelle = libelle;
}
public String getLibelle() {
return libelle;
}
public static MonthEnum valueOf(String month, MonthEnum defaultValue) {
MonthEnum monthEnum = null;
try {
monthEnum = valueOf(month.toUpperCase());
} catch (Exception e) {
log.error(
_("nuitonutil.error.unfound.month", month, defaultValue),
e);
}
return monthEnum == null ? defaultValue : monthEnum;
}
@Override
public String toString() {
// on force la traduction (au cas où i18n n'était pas ini au moment
// du chargement de l'enum...)
return _(libelle);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy