当前位置:网站首页>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());
}
}边栏推荐
- Import export simple
- Library management system
- 3.pyinstaller module introduction
- Unsatisfied dependency expressed through field ‘baseMapper‘; nested exceptio
- A tragedy triggered by "yyyy MM DD" and vigilance before New Year's Day~
- Installing rainbow in various kubernetes with Helm
- 【Spark】Spark SQL 字段血缘如何实现
- 同步通信和异步通信的区别以及优缺点
- C# Nuget离线缓存包安装
- 100 cases of go language
猜你喜欢
随机推荐
架构设计方法
typescript的class结合接口(interface)的简单使用
Load balancer does not have available server for client: userService问题解决
Deeply uncover Ali (ant financial) technical interview process with preliminary preparation and learning direction
Experience the new features of Milvus 2.0 together
Logstash——使用throttle过滤器向钉钉发送预警消息
EFK昇級到ClickHouse的日志存儲實戰
Introduction to the use of TS generics in functions, interfaces and classes
How can an enterprise successfully complete cloud migration?
API and encapsulation of cookies
温度报警器
在web页面播放rtsp流视频(webrtc)
Several promotion routines of data governance
Market trend report, technical innovation and market forecast of microencapsulated chemical pesticides in China
SparseArray
Print bit information of numbers
Understanding of nil in go language
A new paradigm for large model application: unified feature representation optimization (UFO)
如何让主线程等待子线程执行完毕后再执行
Customer Stories | Netease spring breeze: the "spring breeze" of the fun industry, reaching out to all areas through in-depth interaction







