当前位置:网站首页>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
边栏推荐
- 1-18 create the most basic express server & API module for creating routes
- Usbcan analyzer's supporting can and canfd comprehensive test software lkmaster software solves engineers' can bus test problems
- 5g demand in smart medicine
- Nacos部署及使用
- Multi table operation - foreign key constraint
- Rethink healthy diet based on intestinal microbiome
- 1-10 根据不同的url响应客户端的内容
- Reading notes of Clickhouse principle analysis and Application Practice (1)
- Who are you and I
- 给苏丹国安德森苏丹的撒过 d s g
猜你喜欢

Introduction to go web programming: a probe into the excellent test library gocovey

jenkins下载插件下载不了,解决办法

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

Introduce an online platform for multi omics integration and network visual analysis

Multi table operation - foreign key constraint

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

jupyter notebook/lab 切换conda环境

Excitatory neurotransmitter glutamate and brain health

Clickhouse native monitoring item, system table description

用yml文件进行conda迁移环境时的报错小结
随机推荐
【无标题】
Reading notes of Clickhouse principle analysis and Application Practice (1)
Deployment and use of Nacos
周少剑,很少见
ssh 默认端口不是22时的一些问题
Anaconda下安装Jupyter notebook
1-3 使用SQL管理数据库
1-13 express监听GET和POST请求&处理请求
Installing jupyter notebook under Anaconda
VIM common shortcut keys
1-21 jsonp interface
1-10 根据不同的url响应客户端的内容
Nacos部署及使用
SQL server extracts pure numbers from strings
ClickHouse distributed表引擎
Analyse des risques liés aux liaisons de microservices
A group of K inverted linked lists
PyTorch量化实践(1)
qsort函数和模拟实现qsort函数
《ClickHouse原理解析与应用实践》读书笔记(3)