DateFormat 是日期/时间格式化子类的抽象类,它的实现类提供了很多种日期格式化的方法对日期解析和格式化。
TimeZone 表示时区偏移量,接受时区ID,例如:Asia/Shanghai或者GMT+8,根据时区ID获取时区偏移量
DateFormat提供一个方法,setTimeZone(TimeZone zone),接受时区偏移量作为传入参数,为DateFormat日历设置时区,默认情况使用Locale.getDefault()中的本地时区。
SimpleDateFormat timeZoneFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
参考public SimpleDateFormat(String pattern){this(pattern,Locale.getDefault());}
DateFormat常用的parse(String source)和format(Date date) 方法,默认情况下使用本地时区进行解析和格式化时间,如果在解析或者格式化之前,强制设置了时区,则采用设置好的时区进行解析和格式化时间。
SimpleDateFormat timeZoneFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
timeZoneFormat.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
timeZoneFormat.parse("2011-06-29 14:44:25"); //解析成"Asia/Shanghai"时区时间
timeZoneFormat.format(new Date()); // 格式化成"Asia/Shanghai"时区时间
以format为例,format接受
本地时间作为传入参数,计算DateFormat设置的时区与本地时区的时间偏移量(即时差),最终将本地时间格式化成指定时区的时间(parse亦然)
分享到:
相关推荐
调用该类中的方法,实现字符串于日期类型之间的转换,以及包括数据库中的日期类型,避免了代码的重复.
java 使用DateFormat类获取系统的当前时间 java 使用DateFormat类获取系统的当前时间
DateFormatManager dateformat = new DateFormatManager( new char[] { DateString.CENTURY, DateString.MONTH, DateString.DAY, DateString.YEAR, DateString.WEEK, DateString.HOUR_OF_DAY, DateString.MINUTE,...
Date Format with "-"
dateformat - 一个优秀的node.js日期格化包
NULL 博文链接:https://bert82503.iteye.com/blog/2106022
前端项目-jquery-dateFormat,它是一个jquery插件,用于使用javascript格式化日期输出。
sql取日期格式中的年月天时分秒 sql取日期格式中的年月天时分秒
用于转换时间格式, 使用步骤:一. DateFormat dateFormat = new DateFormat();... String timeString=dateFormat.DateFormat("yyyy-MM-dd HH:m:s",time); 参数1:填写需要的格式 参数2:填写需要改变的时间
日期格式 Steven Levithan出色的函数的node.... var dateFormat = require ( "dateformat" ) ; var now = new Date ( ) ; // Basic usage dateFormat ( now , "dddd, mmmm dS, yyyy, h:MM:ss TT" ) ; // Saturday, June
yyyy-MM-dd形式 js timeformat dateformat
Java中DateFormat类.pdf 学习资料 复习资料 教学资源
EXTJS_DATEFORMAT 日期格式对应,网上找到的,挺好用的
本Java精华内容深入Java API、嵌套类和内部类、与时间有关的类Date,DateFormat,Calendar、文件与流、Java变量类型间的相互转换、Java与Web、用连接池提高Servlet访问数据库的效率、Java扩展、应用服务器的集群策略及...
dateFormat日期格式化。
个人资源
jquery-dateFormat, 使用JavaScript格式化日期输出的jQuery插件 使用JavaScript格式输出日期输出的jQuery dateformat插件- 拥有的,jQuery是最小的日期格式库。 ! 安装下载最新的jquery.dateFormat.js 或者 jquery....
DateFormat其本身是一个抽象类,SimpleDateFormat 类是DateFormat类的子类,一般情况下来讲DateFormat类很少会直接使用,而都使用SimpleDateFormat类完成,下面我们具体来看一下两个类的用法:
NULL 博文链接:https://zhaoshunxin.iteye.com/blog/1291905
16_常用API_第2天(正则表达式、Date、DateFormat、Calendar)_讲义