在Java中获取本地化的短星期几名称
使用“a”日期转换字符来显示短的星期几。
System.out.printf("Localized short day name = %ta/%Ta\n", d, d);
上面的d是一个日期对象-
Date d = new Date();
以下是一个例子-
示例
import java.util.Date; import java.text.DateFormat; import java.text.SimpleDateFormat; public class Demo { public static void main(String[] args) throws Exception { Date d = new Date(); DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss a"); String format = dateFormat.format(d); System.out.println("Current date and time = " + format); System.out.printf("Localized day name = %tA/%TA\n", d, d); System.out.printf("Localized short day name = %ta/%Ta\n", d, d); } }
输出结果
Current date and time = 26/11/2018 11:46:45 AM Localized day name = Monday/MONDAY Localized short day name = Mon/MON