SimpleDateFormat转换时间格式】的更多相关文章

SimpleDateFormat有两个常用的方法parse和format 其中SimpleDateFormat在创建时有一下集中格式可以选择 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd") * 支持格式为 yyyy.MM.dd G 'at' hh:mm:ss z 如 '2002-1-1 AD at 22:10:59 PSD'<br>    * yy/MM/dd HH:mm:ss 如 '2002/1/1 17…
SimpleDateFormat转换时间,12,24时间格式 来自:http://blog.csdn.net/dongguang1082/article/details/4387165 在使用SimpleDateFormat时格式化时间的 yyyy.MM.dd 为年月日而如果希望格式化时间为12小时制的,则使用hh:mm:ss 如果希望格式化时间为24小时制的,则使用HH:mm:ss Date d = new Date(); SimpleDateFormat ss = new SimpleDat…
Date日期类 Date表示特定的时间,精确到毫秒; 构造方法: public Data() public Date(long date) 常用方法: public long getTime() public void setTime(long time) public Boolean before(Date when) public Boolean after(Date when) public int compareTo(Date anotherDate) public String toS…
在 Java 里面有很多特别方便的函数(尽管术语可能不这么说)可以供我们使用,让一些本来要写好长好多的代码的事情变得仅仅几行就解决了. 在 SimpleDateFormat 中,有以下特定的规则: G 年代标志符     y 年     M 月     d 日     h 时(在上午或者下午 12小时制)     H 时(在一天中 24小时制) m 分     s 秒     S 毫秒     E 星期     D 一年中的第几天     z 时区     F 一月中第几个星期几     w 一…
Date d = new Date(); SimpleDateFormat ss = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");//12小时制 System.out.println(ss.format(d)); Date date = new Date(); SimpleDateFormat sdformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//24小时制 St…
1------------------------------------------------------------------------------------- package com.neusoft.date; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class SimpleDateFormat01 { public stati…
java中使用SimpleDateFormat类的构造函数SimpleDateFormat(String str)构造格式化日期的格式, 通过format(Date date)方法将指定的日期对象格式化为指定格式的字符串. SimpleDateFormat构造函数中字符串的格式,以及各部分代表的含义: import java.text.SimpleDateFormat; import java.util.Date; public class test{ public static void ma…
先看一个代码示例: import java.text.SimpleDateFormat; import java.util.Date; public class test{ public static void main(String args[]) { Date newTime = new Date(); //设置时间格式 SimpleDateFormat sdf1 = new SimpleDateFormat("y-M-d h:m:s a E"); SimpleDateFormat…
SimpleDateFormat : 可以选择任何用户定义的日期-时间格式的模式    "yyyy-MM-dd HH:mm:ss:SSS"1.格式化:Date -->String            String  format(Date date) 将Date格式化为日期/时间字符串2.解析:String -->Date          Date parse(String source) 将符合格式的指定字符串转换为Date public class SimpleDa…
前言 java中使用SimpleDateFormat类的构造函数SimpleDateFormat(String str)构造格式化日期的格式,通过format(Date date)方法将指定的日期对象格式化为指定格式的字符串. 实战样例 public static void main(String args[]) { //设置时间格式 SimpleDateFormat sdf1 = new SimpleDateFormat("y-M-d h:m:s a E"); SimpleDateF…