`
wgbaoweii
  • 浏览: 28625 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

本周日期

阅读更多

<!--?xml version="1.0" encoding="UTF-8" standalone="no"?--> SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

Calendar c = Calendar.getInstance();
int weekday = c.get(7) - 1;
c.add(5, -weekday);
System.out.println("JAVA-API,本周开始时间:" + sdf.format(c.getTime()));
c.add(5, 6);
System.out.println("JAVA-API,本周开始结束:" + sdf.format(c.getTime()));

Calendar c3 = Calendar.getInstance();
int dayofweek = c3.get(Calendar.DAY_OF_WEEK) - 1;
if (dayofweek == 0){
dayofweek = 7;
}
c3.add(Calendar.DATE, -dayofweek + 1);
System.out.println("国人习惯,本周一:" + sdf.format(c3.getTime()));

Calendar c2 = Calendar.getInstance();
int dayofweek2 = c2.get(Calendar.DAY_OF_WEEK) - 1;
if (dayofweek2 == 0){
dayofweek2 = 7;
}
c2.add(Calendar.DATE, -dayofweek2 + 7);
System.out.println("国人习惯,本周日:" + sdf.format(c2.getTime()));

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics