java.time.Month.getDisplayName() 方法
描述
java.time.Month.getDisplayName(TextStyle style, Locale locale) 方法获取文本表示,例如"Jan"或"December"。
声明
以下是 java.time.Month.getDisplayName(TextStyle style, Locale locale) 方法的声明。
public String getDisplayName(TextStyle style, Locale locale)
参数
style − 所需文本的长度,不为空。
locale − 要使用的语言环境,而不是 null。
返回值
月份的文本值,不为空。
示例
下面的例子展示了 java.time.Month.getDisplayName(TextStyle style, Locale locale) 方法的使用。
package com.tutorialspoint;
import java.time.Month;
import java.time.format.TextStyle;
import java.util.Locale;
public class MonthDemo {
public static void main(String[] args) {
Month day = Month.of(3);
System.out.println(day.getDisplayName(TextStyle.SHORT,Locale.ENGLISH));
}
}
让我们编译并运行上面的程序,这将产生下面的结果 −
Mar

