Month getDisplayName(TextStyle style, Locale locale) example
Description
Month getDisplayName(TextStyle style, Locale locale)
gets the textual representation, such as 'Jan' or 'December'.
Syntax
getDisplayName
has the following syntax.
public String getDisplayName(TextStyle style, Locale locale)
Example
The following example shows how to use getDisplayName
.
import java.time.LocalDate;
import java.time.Month;
import java.time.format.TextStyle;
import java.util.Locale;
//from w ww . java 2 s .c om
public class Main {
public static void main(String[] args) {
Month m = Month.from(LocalDate.now());
System.out.println(m.getDisplayName(TextStyle.SHORT,Locale.UK));
}
}
The code above generates the following result.