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));
} }
执行结果如下:

java 获取当前时间及年月日时分秒的更多相关文章
- js获取当前时间的年月日时分秒以及时间的格式化
1.获取当前时间 var myDate = new Date(); 2.获取时间中的年月日时分秒 myDate.getYear(); // 获取当前年份(2位) myDate.getFullYear( ...
- C语言 - 获取系统时间 以年月日时分秒的形式输出
ESP32需要给下位机通过UART发送时间戳,形式是年月日时分秒的十六进制数据包. #include <stdio.h> #include <time.h> int main( ...
- [SoapUI] 获取当前时间包括年月日时分秒来作为命名
import java.text.SimpleDateFormat GregorianCalendar calendar = new GregorianCalendar() def dateForma ...
- 在vue项目中显示实时时间(年月日时分秒)
1.在data中定义一个变量,存储时间 data(){ return { nowTime:'' } }, 2.给定一个div <div>{{nowTime}}</div> 3. ...
- [置顶] java得到前一个月的年月日时分秒
import java.util.Calendar; /** * 得到前一个月的年月日时分秒 * @author Mr.hu * 2013-6-28上午12:00:35 * Class Explain ...
- c#.net 获取时间日期年月日时分秒格式
今天写代码发现两个比较不错的分享下:1.DateTime.ParseExact很多时候我们获取的时间是数字形式表示的,好比20140127134015.927856,通过这个方法DateTime.Pa ...
- c#.net 获取时间日期年月日时分秒生成自动文件名格式
下面是日期和时间的各种方法,转换为字符串. 如果把输出的格式改下就可以做类似的文件名了,例如:2016010110101224356.doc c#用DateTime.Now.ToString(&qu ...
- JaveWeb 公司项目(5)----- Java获取当前时间的年月日以及同Thrift格式的转化
随着项目进度的逐步完成,数据传输和界面基本上已经搭建完成,下面就是一些细节部分的修改 今天博文的主要内容说的是获取当前的时间和同Thrift类型的转化 和C#类似,java也有一个时间类Date,加载 ...
- java获取指定时间的年月日
作者:Night Silent链接:http://www.zhihu.com/question/35650798/answer/63983440来源:知乎著作权归作者所有,转载请联系作者获得授权.1. ...
随机推荐
- jenkins集成自动化部署插件(一) deploy-plugin
在实际情况中项目构建成功,特别是web项目构建成功是需要将war放到对应的服务上面,进行运行(测试的阶段可能就是发布到测试服务器上面)这样只需要指定构建的触发策略就可以自动构建以及部署,省去不少人工的 ...
- Jenkins Master/Slave架构
原文:http://www.cnblogs.com/itech/archive/2011/11/11/2245849.html 一 Jenkins Master/Slave架构 Master/Slav ...
- 312. Burst Balloons
题目: Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented ...
- Java实现cache的基本机制
我这里说的cache不是指CPU和RAM之间的缓存,而是Java应用中间常用的缓存.最常使用的场合就是访问数据库的时候为了提高效率而使用的 cache.一般的用法就是把数据从数据库读到内存,然后之后的 ...
- javascript 阻止冒泡
JS 阻止冒泡 function stopBubble(e) { //如果提供了事件对象,则这是一个非IE浏览器 if(e && e.stopPropagation) { //因此它 ...
- CCNU-线段树练习题-A-单点更新1
A - 单点更新1 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status Des ...
- centos 升级GCC/G++
#get rep yum install centos-release-scl-rh #yum install centos-release-scl # install g++ 5.2.1 yum - ...
- pythonweb自动化测试
from selenium import webdriverimport time def capture(url, save_fn="capture.png"): browser ...
- STL容器的遍历删除
STL容器的遍历删除 今天在对截包程序的HashTable中加入计时机制时,碰到这个问题.对hash_map中的每个项加入时间后,用查询函数遍历hash_map,以删除掉那些在表存留时间比某个阈值长的 ...
- 【Todo】Python的工作原理
参考这篇: http://python.jobbole.com/86086/?from=timeline&isappinstalled=1&nsukey=MWQG%2B7OI4FvdQ ...