DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Join us tomorrow at 1 PM EST: "3-Step Approach to Comprehensive Runtime Application Security"
Save your seat
  1. DZone
  2. Coding
  3. Java
  4. Java 获取指定日期所在周的第一天

Java 获取指定日期所在周的第一天

Nile Black user avatar by
Nile Black
·
May. 22, 09 · Code Snippet
Like (0)
Save
Tweet
Share
1.84K Views

Join the DZone community and get the full member experience.

Join For Free
// 获取指定日期所在周的第一天


      Calendar cal = Calendar.getInstance();
      cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);//这里设置从周一开始,若需要根据系统时区自动获取,则采用下边的方式
      //cal.set(Calendar.DAY_OF_WEEK, cal.getFirstDayOfWeek());//
      System.out.println(cal.getTime());


测试结果

Wed Apr 29 10:24:45 CST 2009		Mon Apr 27 10:24:45 CST 2009
Thu Apr 30 10:24:45 CST 2009		Mon Apr 27 10:24:45 CST 2009
Fri May 01 10:24:45 CST 2009		Mon Apr 27 10:24:45 CST 2009
Sat May 02 10:24:45 CST 2009		Mon Apr 27 10:24:45 CST 2009
Sun May 03 10:24:45 CST 2009		Mon May 04 10:24:45 CST 2009
Mon May 04 10:24:45 CST 2009		Mon May 04 10:24:45 CST 2009
Tue May 05 10:24:45 CST 2009		Mon May 04 10:24:45 CST 2009
Wed May 06 10:24:45 CST 2009		Mon May 04 10:24:45 CST 2009
Thu May 07 10:24:45 CST 2009		Mon May 04 10:24:45 CST 2009
Fri May 08 10:24:45 CST 2009		Mon May 04 10:24:45 CST 2009
Sat May 09 10:24:45 CST 2009		Mon May 04 10:24:45 CST 2009
Java (programming language)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • How to Cut the Release Inspection Time From 4 Days to 4 Hours
  • Efficiently Computing Permissions at Scale: Our Engineering Approach
  • The Enterprise, the Database, the Problem, and the Solution
  • Explaining: MVP vs. PoC vs. Prototype

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: