集册 Java实例教程 使用SimpleDateFormat格式化时区

使用SimpleDateFormat格式化时区

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

415
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
使用SimpleDateFormat格式化时区

 /* 来自 n o w j a v a . c o m - 时  代  Java*/

import java.text.SimpleDateFormat;

import java.util.Date;

 

public class Main {

 

  public static void main(String[] args) {

     Date date = new Date();

     String strDateFormat = "zzz";

     SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat);

     System.out.println("TimeZone in z format : " + sdf.format(date));

     strDateFormat = "zzzz";

     sdf = new SimpleDateFormat(strDateFormat);

     System.out.println("TimeZone in zzzz format : " + sdf.format(date));

     strDateFormat = "Z";

    
展开阅读全文