1. java获取本周日-本周六的时间

Posted on 2015-10-19 21:19  zkx4213  阅读(1441)  评论(0编辑  收藏  举报

Calendar calendar = Calendar.getInstance();
String[] arrDate = new String[5];
String[] arrWeek = new String[5];
for(int i=0; i<5; i++) {
  calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY+i);
  SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd EE");
  String Date1 = dateFormat.format(calendar.getTime());
  String dateStr1 = dateFormat.format(calendar.getTime());
  String[] strArr = dateStr1.split(" ");
  //存放日期
  arrDate[i] = strArr[0];
  //存放周几
  arrWeek[i] = strArr[1];
}

Copyright © 2024 zkx4213
Powered by .NET 8.0 on Kubernetes