mark for pull
This commit is contained in:
@@ -23,7 +23,45 @@ public class DataUtils {
|
||||
|
||||
}
|
||||
|
||||
public List<List<Date>> split(List<Date> value) {
|
||||
List<List<Date>> result = new ArrayList<>();
|
||||
|
||||
int day = value.iterator().next().getDate();
|
||||
List<Date> newListEntry = new ArrayList<>();
|
||||
|
||||
for (Date date : value) {
|
||||
if (date.getDate() == day) {
|
||||
newListEntry.add(date);
|
||||
}
|
||||
else {
|
||||
day = date.getDate();
|
||||
result.add(newListEntry);
|
||||
newListEntry = new ArrayList<>();
|
||||
newListEntry.add(date);
|
||||
}
|
||||
}
|
||||
result.add(newListEntry);//because the last sublist was not added
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String splitToNeed(String s,Integer type){
|
||||
String[] s1 = s.split(" ");
|
||||
String[] split = s1[0].split("-");
|
||||
String year = split[0];
|
||||
String mon = split[1];
|
||||
String day = split[2];
|
||||
if(type == 1 ){
|
||||
//年
|
||||
return year;
|
||||
}else if(type == 2 ){
|
||||
//月
|
||||
return year+"-"+mon;
|
||||
}else {
|
||||
//日
|
||||
return s1[0];
|
||||
}
|
||||
}
|
||||
public static Date getBeforeDate(Integer number){
|
||||
Date date = new Date();//获取当前日期
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");//格式化一下
|
||||
@@ -37,6 +75,19 @@ public class DataUtils {
|
||||
Date day = calendar1.getTime();
|
||||
return day;
|
||||
}
|
||||
public static Date getAfterDate(Integer number){
|
||||
Date date = new Date();//获取当前日期
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");//格式化一下
|
||||
Calendar calendar1 = Calendar.getInstance();//获取对日期操作的类对象
|
||||
//两种写法都可以获取到前三天的日期
|
||||
// calendar1.set(Calendar.DAY_OF_YEAR,calendar1.get(Calendar.DAY_OF_YEAR) -3);
|
||||
//在当前时间的基础上获取前三天的日期
|
||||
calendar1.add(Calendar.DATE, 0+number);
|
||||
//add方法 参数也可传入 月份,获取的是前几月或后几月的日期
|
||||
//calendar1.add(Calendar.MONTH, -3);
|
||||
Date day = calendar1.getTime();
|
||||
return day;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将一组数据固定分组,每组n个元素
|
||||
|
||||
Reference in New Issue
Block a user