How can I get the Month/Weekday names in GWT?
I try it like this, but there must exist a better solution for this problem (i hope 🙂 ):
public String getLocalizedName() {
switch( this ) {
case Januar:
return getMonth( 1 );
case February:
return getMonth( 2 );
case March:
return getMonth( 3 );
case April:
return getMonth( 4 );
case May:
return getMonth( 5 );
case June:
return getMonth( 6 );
case July:
return getMonth( 7 );
case August:
return getMonth( 8 );
case September:
return getMonth( 9 );
case October:
return getMonth( 10 );
case November:
return getMonth( 11 );
case December:
return getMonth( 12 );
}
return "";
}
private String getMonth( int month ) {
return DateTimeFormat.getFormat( DateTimeFormat.PredefinedFormat.MONTH_ABBR ).format( new Date( 2011, month, 1 ) );
}
Not sure if you want to format or just a list of the months/days. The localized string can be obtained
from
DateTimeFormatInfo: