当前位置:网站首页>Get the first and last days of the current month, and the first and last days of the previous month
Get the first and last days of the current month, and the first and last days of the previous month
2022-06-26 06:24:00 【It's very quiet】
The first and last day of last month
import java.text.SimpleDateFormat;
import java.util.Calendar;
public class TestController {
public static void main(String[] args) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
// Get the first day of the current month
Calendar c = Calendar.getInstance();
c.add(Calendar.MONTH,-1);
c.set(Calendar.DAY_OF_MONTH,1);
String dataStart = df.format(c.getTime());
// Get the last day of the month
Calendar c1 = Calendar.getInstance();
c1.add(Calendar.MONTH,-1);
c1.set(Calendar.DAY_OF_MONTH, c1.getActualMaximum(Calendar.DAY_OF_MONTH));
String dataEnd = df.format(c1.getTime());
}
} First and last day of the month :
import java.text.SimpleDateFormat;
import java.util.Calendar;
public class TestController {
public static void main(String[] args) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
// Get the first day of the current month
Calendar c = Calendar.getInstance();
c.set(Calendar.DAY_OF_MONTH,1);
String dataStart = df.format(c.getTime());
// Get the last day of the month
Calendar c1 = Calendar.getInstance();
c1.set(Calendar.DAY_OF_MONTH, c1.getActualMaximum(Calendar.DAY_OF_MONTH));
String dataEnd = df.format(c1.getTime());
}
}边栏推荐
- GoF23—建造者模式
- 浏览器的四大内核:Trident,Gecko,Webkit,Blink
- New generation engineers teach you how to play with alluxio + ml (Part 1)
- Mongodb——使用Mongodb对字段中字符串内容进行截取,并进行分组统计
- Print bit information of numbers
- How to design a good technical scheme
- Gof23 - prototype mode
- 事务与消息语义
- Logstash - logstash pushes data to redis
- Number of connections server database message: error number 2003can't connect to MySQL server on 'server address' (10061)
猜你喜欢

Data visualization practice: Experimental Report

GoF23—原型模式

Gof23 - abstract factory pattern

如何设计好的技术方案

Library management system

Pychart cannot run designer Exe (this application failed to start because no Qt platform plugin could be I appears)

MySQL-09

STM 32 使用cube 生成TIM触发ADC并通过DMA传输的问题

Logstash - logstash pushes data to redis

Message queuing - omnidirectional comparison
随机推荐
Connexion et déconnexion TCP, détails du diagramme de migration de l'état
Import export simple
Gof23 - prototype mode
The sysdig 2022 cloud native security and usage report found that more than 75% of the running containers have serious vulnerabilities
Number of connections server database message: error number 2003can't connect to MySQL server on 'server address' (10061)
GoF23—建造者模式
Use the fast proxy to build your own proxy pool (mom doesn't have to worry about IP being blocked anymore)
Evolution history of qunar Bi platform construction
University Information Management System
Gof23 - factory mode
数据可视化实战:数据可视化
宝塔服务器搭建及数据库远程连接
Typora activation method
Logstash——Logstash向Email发送告警邮件
成水最多的容器
Thread status and stop
volatile应用场景
Redis multithreading and ACL
3.pyinstaller module introduction
数据可视化实战:实验报告