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

📄 dtformat.java

📁 实例精华
💻 JAVA
字号:
import java.util.Date;
import java.util.Locale;
import java.text.*;

public class DTFormat{
	
	public static void main(String[] args){
		
		int[] styles ={DateFormat.FULL,DateFormat.LONG,
		         DateFormat.MEDIUM,DateFormat.SHORT};
		         
		Date today = new Date(); 
		
		DateFormat cnDf,usDf;
		
		Locale cnLocale = new Locale("zh","CN");
		Locale usLocale = new Locale("en","US");
		
		for (int i = 0; i<styles.length; i++){
			
			System.out.println("-----------------");
			System.out.println(styles[i]);
			cnDf = DateFormat.getDateTimeInstance(styles[i],styles[i],cnLocale);
			System.out.println("中文格式:"+cnDf.format(today));
			
		   
			usDf = DateFormat.getDateTimeInstance(styles[i],styles[i],usLocale);
			System.out.println("美国格式:"+usDf.format(today));
			
		}        
		
	}

}

⌨️ 快捷键说明

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