集册 Java实例教程 使用DateFormat以默认格式格式化日期

使用DateFormat以默认格式格式化日期

欢马劈雪     最近更新时间:2020-01-02 10:19:05

465
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
使用DateFormat以默认格式格式化日期


import java.text.DateFormat;

import java.util.Date;

 /*来 自 时 代 J a v a*/

public class Main {

 

  public static void main(String[] args) {

   

    Date date = new Date();

 

    String strDate = DateFormat.getDateInstance(DateFormat.SHORT).format(date);

    System.out.println(strDate);

 

    strDate = DateFormat.getDateInstance(DateFormat.MEDIUM).format(date);

    System.out.println(strDate);    
    /** 
    来 自 
    nowjava.com - 时代Java
    **/

 

    strDate = DateFormat.getDateInstance(DateFormat.LONG).format(date);

    System.
展开阅读全文