Index: lutinutil/src/java/org/codelutin/util/MonthEnum.java diff -u /dev/null lutinutil/src/java/org/codelutin/util/MonthEnum.java:1.1 --- /dev/null Sun Jan 6 12:53:58 2008 +++ lutinutil/src/java/org/codelutin/util/MonthEnum.java Sun Jan 6 12:53:53 2008 @@ -0,0 +1,65 @@ +/* +* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Code Lutin, +* Tony Chemit +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* 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 Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* ##% */ +package org.codelutin.util; + +import static org.codelutin.i18n.I18n._; + +/** + * Une énumération pour représenter les mois d'une année. + * + * @author chemit + */ +public enum MonthEnum { + JANUARY(_("lutinutil.mounth.january")), + FEBRUARY(_("lutinutil.mounth.february")), + MARCH(_("lutinutil.mounth.march")), + APRIL(_("lutinutil.mounth.april")), + MAY(_("lutinutil.mounth.may")), + JUNE(_("lutinutil.mounth.june")), + JULY(_("lutinutil.mounth.july")), + AUGUST(_("lutinutil.mounth.august")), + SEPTEMBER(_("lutinutil.mounth.september")), + OCTOBER(_("lutinutil.mounth.october")), + NOVEMBER(_("lutinutil.mounth.november")), + DECEMBER(_("lutinutil.mounth.december")); + + 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 = MonthEnum.valueOf(month.toUpperCase()); + } catch (IllegalArgumentException e) { + System.err.println(_("lutinutil.error.unfound.month", month, defaultValue)); + } catch (NullPointerException e) { + System.err.println(_("lutinutil.error.unfound.month", month, defaultValue)); + } + return monthEnum == null ? defaultValue : monthEnum; + } + + +} \ No newline at end of file