获取时间的方式
来源:互联网 发布:淘宝有客服电话 编辑:程序博客网 时间:2024/05/22 02:02
Calendar:
Calendar now = Calendar.getInstance(); System.out.println("年: " + now.get(Calendar.YEAR)); System.out.println("月: " + (now.get(Calendar.MONTH) + 1) + ""); System.out.println("日: " + now.get(Calendar.DAY_OF_MONTH)); System.out.println("时: " + now.get(Calendar.HOUR_OF_DAY)); System.out.println("分: " + now.get(Calendar.MINUTE)); System.out.println("秒: " + now.get(Calendar.SECOND)); System.out.println("当前时间毫秒数:" + now.getTimeInMillis()); System.out.println(now.getTime());
Day:
Date d = new Date(); System.out.println(d); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String dateNowStr = sdf.format(d); System.out.println("格式化后的日期:" + dateNowStr); String str = "2012-1-13 17:26:33"; //要跟上面sdf定义的格式一样 Date today = sdf.parse(str); System.out.println("字符串转成日期:" + today);
0 0
- 获取时间的方式
- 获取时间的方式
- 前端获取时间的方式
- C++获取系统时间的方式
- 获取时间的几种方式
- linux 使用程序获取时间的方式
- Android获取UTC时间的方式
- C++获取系统时间的方式
- C++获取系统时间的方式
- 获取当前日期、时间的方式
- VC中三种获取本地时间的方式
- C语言获取系统时间的方式
- 时间Date的各种获取方式
- C获取时间的两种方式
- 获取系统时间的几种方式
- JAVA获取当前系统时间的方式
- 获取时间最简单的方式
- IOS获取当前的系统时间的三种方式
- 关于事件分发
- UVA 1728 Toll Management IV
- linux下IPC配置
- 使用Xcode8上传成功后,商店里构建版本却没有应用
- PHP的Socket网络编程入门指引
- 获取时间的方式
- Centos6下通过pssh并发执行命令
- Blind Java Deserialization - Part II - exploitation rev 2
- android studio中的Menu
- Objective-C-iOS UIScrollView UIPageControl 的用法详解
- lua math函数库
- materialdesign之tablayout的用法
- 无人驾驶车核心算法 — SLAM
- MongoDB的数据复制和数据切片