特定于语言环境的上午/下午指示器是AM / PM标记指示器。
使用“ p”转换字符显示AM / PM。
System.out.printf("Morning/afternoon indicator: %tp",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("\nMorning/afternoon indicator: %Tp",d); } }
输出结果
Morning/afternoon indicator: pm Morning/afternoon indicator: PM