使用SimpleDateFormat格式化日期

SimpleDateFormat是一个以语言环境敏感的方式来格式化和分析日期的类。SimpleDateFormat允许你选择任何用户自定义日期时间格式来运行。例如:

import java.util.*;
import java.text.*;

public class DateDemo {
   public static void main(String args[]) {

      Date dNow = new Date( );
      SimpleDateFormat ft = 
      new SimpleDateFormat ("E yyyy.MM.dd 'at' hh:mm:ss a zzz");

      System.out.println("Current Date: " + ft.format(dNow));
   }
}
尝试一下 »

以上实例编译运行结果如下:

Current Date: Sun 2004.07.18 at 04:14:09 PM PDT

 

相关文章:

  • 2021-08-26
  • 2022-12-23
  • 2022-12-23
  • 2022-03-07
  • 2022-01-21
  • 2021-11-04
  • 2021-05-28
  • 2021-05-27
猜你喜欢
  • 2021-06-18
  • 2022-12-23
  • 2021-10-08
  • 2021-11-13
  • 2021-08-19
  • 2021-05-18
  • 2022-12-23
相关资源
相似解决方案