提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
使用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";