当前位置:网站首页>Get the array list of the previous n days and the previous and subsequent days of the current time, and cycle through each day
Get the array list of the previous n days and the previous and subsequent days of the current time, and cycle through each day
2022-07-27 16:43:00 【Young people in Baima town】
Recently, a requirement appeared in the project , Before and after the current date N God choose , Get date
import java.text.DateFormat; import java.text.ParsePosition; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; import java.util.Date; import java.util.List;
-----------------------------------------------------------------------------------
String afterTime; String fetureTime; List<String> listDatefan;
stay viewCreate The following code is written in this method
DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); afterTime = df.format(new Date().getTime() - 15 * 24 * 60 * 60 * 1000);// Before 15 God , fetureTime = df.format(new Date().getTime() + 15 * 24 * 60 * 60 * 1000);// future 15 God String nowTime = df.format(new Date());// current time handleCirculationDate(fetureTime, afterTime); binding.tvTime.setSelected(true); listDatefan = new ArrayList<>(); // trans Collections.reverse(listDate); for (String n : listDate) { listDatefan.add(n); }
List<String> listDate; public List<String> handleCirculationDate(String fetureTime, String afterTime) { listDate = new ArrayList<>(); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");// Date format try { Date startDate = dateFormat.parse(afterTime);// Before Date endDate = dateFormat.parse(fetureTime);// future Calendar calendar = Calendar.getInstance(); calendar.setTime(startDate);// Previous while (calendar.getTime().before(endDate)) { listDate.add(dateFormat.format(calendar.getTime())); calendar.add(Calendar.DAY_OF_MONTH, 1); } return listDate; } catch (Exception e) { e.printStackTrace(); } return null; }
边栏推荐
- How PHP changes a two-dimensional array into a one-dimensional array
- Configuration and application of gurobi in pycharm
- 【论文阅读】A CNN-transformer hybrid approach for decoding visual neuralactivity into text
- Replication of complex linked list
- Is low code the future of development? On low code platform
- CDQ divide and conquer and whole dichotomy learning notes
- Addition of large numbers
- Handling of multiple parts with duplicate names and missing parts when importing SOLIDWORK assemblies into Adams
- TP5 -- query field contains a certain --find of search criteria_ IN_ SET
- DRF learning notes (I): Data Serialization
猜你喜欢

减小PDF文档大小(转载)

kubesphere多节点安装出错

Cvxpy - latest issue

my_ls小结

Gurobi——GRBLinExpr

【论文阅读】Transformer with Transfer CNN for Remote-Sensing-ImageObject Detection
![[paper reading] a CNN transformer hybrid approach for coding visual neuralactivity into text](/img/31/d6d7ac43c3170c0d527d88053618c9.png)
[paper reading] a CNN transformer hybrid approach for coding visual neuralactivity into text

Reduce PDF document size (Reprint)

Flowable process custom attribute

DRF learning notes (IV): DRF view
随机推荐
CDQ divide and conquer and whole dichotomy learning notes
Clear understanding of torchvision (mind map)
CCF-201312-1
gpt-2 文本生成
The first week of C language learning - the history of C language
TP5 rewrite paging
Simulation生成报表
excel skill
Chat skills
使用百度飞桨EasyDL实现电商UGC图片自动分类
string数字类型转换为千分位
TP5 -- query field contains a certain --find of search criteria_ IN_ SET
重新配置cubemx后,生成的代码用IAR打开不成功
[paper reading] single- and cross modality near duplicate image pairsdetection via spatial transformer compare
DRF learning notes (III): model class serializer modelserializer
Gurobi——GRBLinExpr
【论文阅读】Single- and Cross-Modality Near Duplicate Image PairsDetection via Spatial Transformer Compar
Log management
Json数据的格式使用
The class declared by the scala object keyword directly calls methods and associated objects