当前位置:网站首页>开发技术-获取10分钟前的时间
开发技术-获取10分钟前的时间
2022-06-30 20:35:00 【JustDI-CM】
SimpleDateFormat:用于日期格式化
Calendar:用于时间操作
Date:用于获取时间
java 日期格式化-- SimpleDateFormat 的使用。字符串转日期,日期转字符串
Java Calendar 日历类的时间操作 Timestamp Date Calendar 相互转换
代码1:
// SimpleDateFormat 日期格式化
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar rightNow = Calendar.getInstance();
Date dt = new Date();
System.out.println("当前时间---" + sdf.format(dt));
rightNow.setTime(dt);
rightNow.add(Calendar.MINUTE, -10);
Date dt2 = rightNow.getTime();
String format = sdf.format(dt2);
System.out.println("减少十分钟---" + format);代码2:
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date now = new Date();
System.out.println("当前时间---" + sdf.format(now));
// 十分钟的毫秒数
// long time = 10 * 60 * 1000;
// 九分半的毫秒数
long time = 570000;
Date beforeDate = new Date(now.getTime() - time);
System.out.println("九分半前---" + sdf.format(beforeDate));代码1只能实现整数功能,代码2比较灵活
边栏推荐
- Testing principle and precautions of biovendor rage ELISA Kit
- Lumiprobe nucleic acid quantitative qudye dsDNA br detection kit
- Deflection lock / light lock / heavy lock lock is healthier. How to complete locking and unlocking
- B_QuRT_User_Guide(33)
- Maya house modeling
- Lumiprobe copper free click chemical solution
- 在线教育项目用户登录和注册
- Summary of PHP file upload (garbled code, move failure, permission, display picture)
- Evolution of screen display technology
- Jerry's question about long press boot detection [chapter]
猜你喜欢

Binary search tree (1) - concept and C language implementation

哈夫曼树(一)基本概念与C语言实现
![翻转链表II[翻转链表3种方式+dummyHead/头插法/尾插法]](/img/a8/6472e2051a295f5e42a88d64199517.png)
翻转链表II[翻转链表3种方式+dummyHead/头插法/尾插法]
![Jerry's touch key recognition process [chapter]](/img/cf/8dacbb7f80e427276df6201dddd377.png)
Jerry's touch key recognition process [chapter]

哈夫曼樹(一)基本概念與C語言實現

NLP paper lead reading | what about the degradation of text generation model? Simctg tells you the answer

qiao-npms:搜索npm包

MySQL introduction, detailed installation steps and usage | dark horse programmer

Is the project manager a leader? Can you criticize and blame members?

1. Introduction to generating countermeasures network
随机推荐
Web host iptables firewall security script
Lumiprobe copper free click chemical solution
A complete collection of vulnerability scanning tools. Mom doesn't have to worry that I won't find any more vulnerabilities
判断js对象是否为空的方式
Go language identifier and package name specification
Halcon knowledge: check the measurement objects [1]
B_QuRT_User_Guide(33)
【数字IC应届生职业规划】Chap.1 IC行业产业链概述及代表企业大厂汇总
QT qstringlist usage
No "history of blood and tears" in home office | community essay solicitation
Lumiprobe生物素亚磷酰胺(羟脯氨酸)说明书
Evolution of screen display technology
19.04 distributor
哈夫曼树(一)基本概念与C语言实现
qiao-npms:搜索npm包
Jenkins can't pull the latest jar package
北京大学ACM Problems 1004:Financial Management
Black apple server system installation tutorial, black apple installation tutorial, teach you how to install black apple in detail [easy to understand]
Jerry's touch key recognition process [chapter]
coredns 修改upstream