当前位置:网站首页>Develop technology - get time 10 minutes ago
Develop technology - get time 10 minutes ago
2022-06-30 21:49:00 【JustDI-CM】
SimpleDateFormat: Used for date formatting
Calendar: For time operation
Date: Used to get the time
java Date formatting -- SimpleDateFormat Use . String to date , Date to string
Java Calendar Calendar time operation Timestamp Date Calendar transformation
Code 1:
// SimpleDateFormat Date formatting
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar rightNow = Calendar.getInstance();
Date dt = new Date();
System.out.println(" current time ---" + sdf.format(dt));
rightNow.setTime(dt);
rightNow.add(Calendar.MINUTE, -10);
Date dt2 = rightNow.getTime();
String format = sdf.format(dt2);
System.out.println(" Ten minutes less ---" + format);Code 2:
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date now = new Date();
System.out.println(" current time ---" + sdf.format(now));
// The number of milliseconds in ten minutes
// long time = 10 * 60 * 1000;
// Nine and a half milliseconds
long time = 570000;
Date beforeDate = new Date(now.getTime() - time);
System.out.println(" Nine and a half minutes ago ---" + sdf.format(beforeDate));Code 1 Only integer function can be realized , Code 2 More flexible
边栏推荐
- Clickhouse Native Monitoring item, System table Description
- A group of K inverted linked lists
- The programmer's girlfriend gave me a fatigue driving test
- 开发属于自己的包
- 兴奋神经递质——谷氨酸与大脑健康
- 艾芬医生事件解析
- To the Sultanate of Anderson
- CA I ah, several times Oh, ah, a sentence IU home Oh
- 1-11 create online file service
- Five years after graduation, I wondered if I would still be so anxious if I hadn't taken the test
猜你喜欢

程序员女友给我做了一个疲劳驾驶检测

Rethink healthy diet based on intestinal microbiome

Reading notes of Clickhouse principle analysis and Application Practice (2)

Look at the top 10 capabilities of alicloud cipu

USBCAN分析仪的配套CAN和CANFD综合测试软件LKMaster软件解决工程师CAN总线测试难题

《ClickHouse原理解析与应用实践》读书笔记(3)

Clickhouse native monitoring item, system table description

A comprehensive understanding of gout: symptoms, risk factors, pathogenesis and management

Ten security measures against unauthorized access attacks

jupyterbook 清空控制台输出
随机推荐
1-10 根据不同的url响应客户端的内容
SQL server extracts pure numbers from strings
1-14 express managed static resources
Side sleep ha ha ha
Pytorch quantitative practice (2)
What happens when word encounters an error while trying to open a file?
Ssh server configuration file parameter permitrootlogin introduction
What does grade evaluation mean? What is included in the workflow?
Anaconda下安装Jupyter notebook
盘点华为云GaussDB(for Redis)六大秒级能力
《ClickHouse原理解析与应用实践》读书笔记(2)
Develop your own package
Inventory the six second level capabilities of Huawei cloud gaussdb (for redis)
clickhouse原生监控项,系统表描述
Summary of errors reported when using YML file to migrate CONDA environment
ML&DL:机器学习和深度学习中超参数优化的简介、评估指标、过拟合现象、常用的调参优化方法之详细攻略
Understand what MySQL index push down (ICP) is in one article
1-2 安装并配置MySQL相关的软件
Look at the top 10 capabilities of alicloud cipu
Open the jupyter notebook/lab and FAQ & settings on the remote server with the local browser