1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.nuiton.util;
24
25 import org.apache.commons.logging.Log;
26 import org.apache.commons.logging.LogFactory;
27
28 import static org.nuiton.i18n.I18n.t;
29
30
31
32
33
34
35
36 public enum MonthEnum {
37
38 JANUARY(t("nuitonutil.month.january")),
39 FEBRUARY(t("nuitonutil.month.february")),
40 MARCH(t("nuitonutil.month.march")),
41 APRIL(t("nuitonutil.month.april")),
42 MAY(t("nuitonutil.month.may")),
43 JUNE(t("nuitonutil.month.june")),
44 JULY(t("nuitonutil.month.july")),
45 AUGUST(t("nuitonutil.month.august")),
46 SEPTEMBER(t("nuitonutil.month.september")),
47 OCTOBER(t("nuitonutil.month.october")),
48 NOVEMBER(t("nuitonutil.month.november")),
49 DECEMBER(t("nuitonutil.month.december"));
50
51
52 private static final Log log = LogFactory.getLog(MonthEnum.class);
53
54 private final String libelle;
55
56 MonthEnum(String libelle) {
57 this.libelle = libelle;
58 }
59
60 public String getLibelle() {
61 return libelle;
62 }
63
64 public static MonthEnum valueOf(String month, MonthEnum defaultValue) {
65 MonthEnum monthEnum = null;
66 try {
67 monthEnum = valueOf(month.toUpperCase());
68 } catch (Exception e) {
69 log.error(
70 t("nuitonutil.error.unfound.month", month, defaultValue),
71 e);
72 }
73 return monthEnum == null ? defaultValue : monthEnum;
74 }
75
76 @Override
77 public String toString() {
78
79
80 return t(libelle);
81 }
82 }