获取android中的 SimpleDateFormat——获取当前时间
2014-12-19 11:06
260 查看
public class Ceshi {
public static void main(String[] args) throws ParseException {
SimpleDateFormat CeshiFmt0=new SimpleDateFormat("Gyyyy年MM月dd日 HH时mm分ss秒");
SimpleDateFormat CeshiFmt1=new SimpleDateFormat("yyyy/MM/dd HH:mm");
SimpleDateFormat CeshiFmt2=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat CeshiFmt3=new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒 E ");
SimpleDateFormat CeshiFmt4=new SimpleDateFormat("yyyy/MM/dd E");
SimpleDateFormat CeshiFmt5=new SimpleDateFormat(
"一年中的第 D 天 ,第w个星期 ,一个月中第W个星期 ,k时 z时区");
Date now=new Date();
System.out.println(CeshiFmt0.format(now));
System.out.println(CeshiFmt1.format(now));
System.out.println(CeshiFmt2.format(now));
System.out.println(CeshiFmt3.format(now));
System.out.println(CeshiFmt4.format(now));
System.out.println(CeshiFmt5.format(now));
}
SimpleDateFormat formatter = new SimpleDateFormat ("yyyy年MM月dd日 HH:mm:ss ");
Date curDate = new Date(System.currentTimeMillis());//获取当前时间
String str = formatter.format(curDate);
}
结果为: 公元2010年07月27日 09时19分29秒
2010/07/27 09:19
2010-07-27 09:19:29
2010年07月27日 09时19分29秒 星期二
2010/07/27 星期二
一年中的第 208 天 ,第31个星期 ,一个月中第5个星期 ,9时 CST时区
public static void main(String[] args) throws ParseException {
SimpleDateFormat CeshiFmt0=new SimpleDateFormat("Gyyyy年MM月dd日 HH时mm分ss秒");
SimpleDateFormat CeshiFmt1=new SimpleDateFormat("yyyy/MM/dd HH:mm");
SimpleDateFormat CeshiFmt2=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat CeshiFmt3=new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒 E ");
SimpleDateFormat CeshiFmt4=new SimpleDateFormat("yyyy/MM/dd E");
SimpleDateFormat CeshiFmt5=new SimpleDateFormat(
"一年中的第 D 天 ,第w个星期 ,一个月中第W个星期 ,k时 z时区");
Date now=new Date();
System.out.println(CeshiFmt0.format(now));
System.out.println(CeshiFmt1.format(now));
System.out.println(CeshiFmt2.format(now));
System.out.println(CeshiFmt3.format(now));
System.out.println(CeshiFmt4.format(now));
System.out.println(CeshiFmt5.format(now));
}
SimpleDateFormat formatter = new SimpleDateFormat ("yyyy年MM月dd日 HH:mm:ss ");
Date curDate = new Date(System.currentTimeMillis());//获取当前时间
String str = formatter.format(curDate);
}
结果为: 公元2010年07月27日 09时19分29秒
2010/07/27 09:19
2010-07-27 09:19:29
2010年07月27日 09时19分29秒 星期二
2010/07/27 星期二
一年中的第 208 天 ,第31个星期 ,一个月中第5个星期 ,9时 CST时区
相关文章推荐
- JAVA开发9--获取当前时间--SimpleDateFormat
- Android --- 获取12/24制系统时间(使用SimpleDateFormat和Calendar)
- 获取当前时间,并以要求格式展示SimpleDateFormat
- java获取当前时间后,经SimpleDateFormat格式化成String类型,差8小时
- SimpleDateFormat获取时间的注意事项
- Android 开发之 SimpleDateFormat 类解析&输出指定格式的日期时间字符串
- android 利用SimpleDateFormat格式化时间不准确的问题
- 时间获取与转换Calendar/SimpleDateFormat
- 使用DateFormat类获取系统的当前时间
- java获取前一天时间SimpleDateFormat,java判断某个时间段
- Android SimpleDateFormat转换时间 12,24时间格式
- android 利用SimpleDateFormat格式化时间不准确的问题
- 输入日期,计算出与当前系统日期相隔多少天(获取系统时间,年月日分别获取,对其进行格式化simpledateformat;输入的日期类似操作)
- 获取想要格式的时间 simpledateformat
- 获取时间Calendar、使用 Date 和 SimpleDateFormat 类表示时间
- 使用SimpleDateFormat类获取完整的日期时间实例
- 通过SimpleDateFormat获取相关时间日期信息
- js 的date的format时间,获取当前时间,前一天的日期
- 获取时间Calendar、使用 Date 和 SimpleDateFormat 类表示时间
- 【转】Android SimpleDateFormat转换时间 12,24时间格式