⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testdateformat.java

📁 由浅入深的介绍JAVAse的基本编程思想
💻 JAVA
字号:
import java.util.Date;
import java.util.Locale;
import java.text.DateFormat;

public class TestDateFormat{
	public static void main(String args[]){
		Date d = new Date();
		Locale locale1 = new Locale("zh","CN");
		Locale locale2 = new Locale("en","US");
		
		test(d,locale1);
		System.out.println("----------------------");
		test(d,locale2);
	}
	public static void test(Date d,Locale locale){
		DateFormat df1 = DateFormat.getDateTimeInstance();
		DateFormat df2 = DateFormat.getDateTimeInstance(DateFormat.SHORT,DateFormat.SHORT,locale);
		DateFormat df3 = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,DateFormat.MEDIUM,locale);
		DateFormat df4 = DateFormat.getDateTimeInstance(DateFormat.LONG,DateFormat.LONG,locale);
		DateFormat df5 = DateFormat.getDateTimeInstance(DateFormat.FULL,DateFormat.FULL,locale);		
		System.out.println(df1.format(d));
		System.out.println(df2.format(d));
		System.out.println(df3.format(d));
		System.out.println(df4.format(d));
		System.out.println(df5.format(d));
	}		
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -