在 Java 中运用 printf 方法显示本地化的月份名称
若要在 Java 中显示本地化的月份名称,请使用转换字符“B”。
System.out.printf("Localized month : %TB", d);若要以小写显示方法名称,请使用“%tb”。
System.out.printf("
Localized month : %tB
", d);示例
import java.util.Date;
public class Demo {
public static void main(String[] args) {
Date d = new Date();
System.out.printf("Morning/afternoon indicator: %tp",d);
System.out.printf("
Morning/afternoon indicator: %Tp",d);
System.out.printf("
Localized month : %tB
", d);
System.out.printf("Localized month : %TB", d);
}
}输出
Morning/afternoon indicator: pm Morning/afternoon indicator: PM Localized month : November Localized month : NOVEMBER
在 Java 中右对齐和左对齐值
广告
数据结构
联网
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP