java使用Calendar 获取七天的时间
作者:互联网
@Test
public void Tes1(){
String [] arr = new String[7];
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = null;
for (int i=0;i<7;i++){
c=Calendar.getInstance();
c.add(Calendar.DAY_OF_MONTH, -i);
arr[6-i] =sdf.format(c.getTime());
}
for (int i = 0; i < arr.length; i++) {
System.err.println(arr[i]);
}
}
标签:七天,java,String,SimpleDateFormat,new,Calendar,null 来源: https://www.cnblogs.com/java-six/p/16538992.html