0 votes
420 views
in Java by
How will you get next Sunday by using java8?

1 Answer

0 votes
by (5k points)
See the following running example to get next Sunday by using java 8:-

package com.java8.date;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.temporal.TemporalAdjusters;

public class GetNextSunday {

    public static void main(String[] args) {
        //get the next Sunday
        LocalDate today = LocalDate.now();
        LocalDate nextTuesday = today.with(TemporalAdjusters.next(DayOfWeek.SUNDAY));
        System.out.println("Today: "+today);
        System.out.println("Next Sunday : " + nextTuesday);
    }

}

Output:-
Today: 2019-01-31
Next Sunday : 2019-02-03

Share:- Whatsapp Facebook Facebook


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

Categories

...