0 votes
in Java by
How to get current week start and end date in Java?

1 Answer

0 votes
by (5k points)
package com;

import java.util.Calendar;
import java.util.Date;

public class CurrentWeek {

    public static void main(String[] args) {
        Calendar currentCalendar = Calendar.getInstance();
        Date currentWeekStart = currentCalendar.getTime();

        currentCalendar.add(Calendar.DATE, 6); //add 6 days after Monday
        Date currentWeekEnd = currentCalendar.getTime();

        System.out.println("Week Start Date: " + currentWeekStart);
        System.out.println("Week End Date: " + currentWeekEnd);

Week Start Date: Thu Mar 01 13:00:29 IST 2018
Week End Date: Wed Mar 07 13:00:29 IST 2018

Share:- Whatsapp Facebook Facebook

Welcome to Developerhelpway Q&A, where you can ask questions and receive answers from other members of the community.