2017.4.16 java 获取当前时间及年月日时分秒
java代码如下:
package test;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class Test {
public static void main(String[] args) {
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));
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" );
System.out.println( "当前时间:" + sdf.format(d));
}
}
|
执行结果如下:
转载于:https://www.cnblogs.com/mojiayi/p/6717784.html
2017.4.16 java 获取当前时间及年月日时分秒相关推荐
- JAVA 获取当前时间(年月日时分秒)
LocalDateTime单独获取年月日和时分秒 LocalDateTime localDateTime = LocalDateTime.now(); localDateTime.format(Dat ...
- python 获取当前时间(年月日时分秒)
python 获取当前时间(年月日时分秒) now_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
- JS获取当前时间(年月日时分秒)
JS获取当前时间(年月日时分秒) JS获取当前时间(年月日时分秒) 代码直接撸: **拿走直接用 `//获取当前时间 getNowTime() { var date = new Date(); //年 ...
- php获取当前时间的年月日时分秒格式
php获取当前时间的年月日时分秒 解决方法: $now_time= time(); 年月日时分秒格式:http://www.yayihouse.com/yayishuwu/chapter/1727
- js获取当前时间的年月日时分秒以及时间的格式化
1.获取当前时间 var myDate = new Date(); 2.获取时间中的年月日时分秒 myDate.getYear(); // 获取当前年份(2位) myDate.getFullYear( ...
- java获取指定格式的年月日时分秒时间
/*** 通过Date类获取*/@Testpublic void getTimeNowThroughDate(){Date date=new Date();SimpleDateFormat simpl ...
- js获取当前时间的年月日时分秒
let time = new Date(); let timeInfo = (time.getFullYear()+'年'+time.getMonth()+'月'+time.getDate()+'日' ...
- 【python】获取当前时间(年月日时分秒)
需要用到 time 包,这个包python自带,无需另外下载. 想要哪个,就在字符串里输入哪个就行了,它会自动匹配的. import time print(time.strftime('%Y-%m-% ...
- 东八区时间转换为年月日时分秒(2020-10-26T11:34:30Z转换为2020-10-26 11:34:30)
将东八区时间转换为年月日时分秒 //直接上demofunction rTime(date) {var json_date = new Date(date).toJSON();return new Da ...
- GPS秒转北京时间(年月日时分秒)+ gps 周、周内秒转gps时间戳(单位秒) C++ 代码
目录 一.GPS秒转北京时间(年月日时分秒)- 代码如下: 二.gps
最新文章
- 嵌入式 自旋锁、互斥锁、读写锁、递归锁
- 限制input输入小数只能到3位或者只能输入正整数(兼容ios)
- VirtualBox虚拟机网络环境解析和搭建-NAT、桥接、Host-Only、Internal、端口映射
- For循环(十分重要)
- 参数估计法——最大似然估计和贝叶斯参数估计
- hive取mysql数据oracle数据,Hive安装过程(mysql/oracle存储元数据)详解
- 全球首发!惯性导航导论(剑桥大学)第一部分
- XAML实例教程系列 - 类型转换器(Type Converter)
- Rust :rustup的版本更新功能
- 3DEC离散元数值模拟技术与应用
- 惯性导航系统--百科笔记
- netmeeting的使用方法
- 对称加密算法原理简介
- 计算机英语汇总(保持更新)
- 关于声音的前后左右上下的控制以及单声道立体声的区别
- React父传子、子传父
- 【华为云服务之】在华为云ECS上安装Docker
- php短信接口怎么使用_PHP代码示例_PHP短信接口 | 微米-中国领先的短信彩信接口平台服务商...
- hdu1864最大报销额 (01背包)
- Qt4 Linux下读写excel
热门文章
- 博文有了,告诉吾找不到,这怪谁
- 版本分支不宜间隔太久
- 钉钉人脸识别,戴个太阳帽就找不到人脸
- 键盘按键用硅胶材料更好
- 点评一下阿提亚和黎曼猜想
- html table control,HtmlTable.HtmlTableRowControlCollection
- .net 编译工具_写Java这么久,JDK源码编译过没?编译JDK源码踩坑纪实
- coreldraw+排灯_CorelDRAW打造七彩灯泡
- 深入浅出 MFC -WIN32基本概念
- java 程序出现标点错误,我是学java的新手,下面代码出现报错,请问是什么原因?如何解决?...