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

📄 trydateformats.java

📁 非常好的java事例以及带源码事例的java2教程
💻 JAVA
字号:
// Trying date formatting
import java.util.*;
import java.text.*;

public class TryDateFormats
{
  public static void main(String[] args)
  {
    Date today = new Date();
    Locale[] locales = {Locale.US, Locale.UK,
                        Locale.GERMANY, Locale.FRANCE };  

    int[] styles = { DateFormat.FULL,DateFormat.LONG,
                     DateFormat.MEDIUM,DateFormat.SHORT}; 
    DateFormat fmt;
    String[] styleText = { "FULL", "LONG", "MEDIUM", "SHORT"};    

    // Output the date for each local in four styles
    for(int i = 0; i < locales.length; i++)
    {
      System.out.println("\nThe Date for " + 
                         locales[i].getDisplayCountry() + ":");
      for(int j = 0; j < styles.length; j++)
      {
        fmt = DateFormat.getDateInstance(styles[j], locales[i]);
        System.out.println( "\tIn " + styleText[j] + 
                            " is " + fmt.format(today));
      }
    }
  }
}

⌨️ 快捷键说明

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