当前位置:网站首页>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
边栏推荐
- Document Layout Analysis: A Comprehensive Survey 2019论文学习总结
- [backtracking] full arrangement leetcode46
- vim 常用快捷键
- 1-1 basic concepts of database
- 1-2 安装并配置MySQL相关的软件
- [untitled]
- 看阿里云 CIPU 的 10 大能力
- 1-13 express监听GET和POST请求&处理请求
- JD and Tencent renewed the three-year strategic cooperation agreement; The starting salary rose to 260000 yuan, and Samsung sk of South Korea scrambled for a raise to retain semiconductor talents; Fir
- 5G 在智慧医疗中的需求
猜你喜欢

Prediction and regression of stacking integrated model

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

Jupyter notebook/lab switch CONDA environment

Arcmap|assign values to different categories of IDS with the field calculator

興奮神經遞質——穀氨酸與大腦健康

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

顺祝老吴的聚会

SQL server extracts pure numbers from strings
![[untitled]](/img/42/47a8c8faaed33a1d9e864cb2ef7b72.png)
[untitled]

jupyterbook 清空控制台输出
随机推荐
jupyterbook 清空控制台输出
[untitled] first time to participate in CSDN activities
It is urgent for enterprises to protect API security
Random talk about Clickhouse join
1-14 express托管静态资源
Reading notes of Clickhouse principle analysis and Application Practice (2)
Bloom filter
sdfsdf
1-17 express Middleware
Multi table operation - foreign key constraint
FreeRTOS record (IX. an example of a bare metal project transferring to FreeRTOS)
Clickhouse native monitoring item, system table description
Zaah Sultan looks at the old driver
Develop your own package
给苏丹国安德森苏丹的撒过 d s g
微服务链路风险分析
攻防演练中的防泄露全家福
Microservice link risk analysis
阿婆做的臭豆腐
Summary of errors reported when using YML file to migrate CONDA environment