Java 8 – How to find Date on the day of given Week in a month ?

DeeKay December 6, 2016 at 9:17 pm · java.time

In this Java 8 program we will see how to find date on the day of given week in a month. For example if we want to find the date on 3rd Wednesday of current month.

 

<br />
/**<br />
 * Created on Dec 01, 2016 Copyright(c) http://kodehelp.com All Rights Reserved.<br />
 */<br />
package com.kodehelp.java.util;</p>
<p>import java.time.DayOfWeek;<br />
import java.time.LocalDate;<br />
import java.time.temporal.TemporalAdjusters;</p>
<p>/**<br />
 * @author http://kodehelp.com<br />
 */<br />
public class DateTimeJava8 {</p>
<p>    public static void main(String args[]){</p>
<p>        LocalDate localDate = LocalDate<br />
                                    .now()<br />
                                    .with(TemporalAdjusters.dayOfWeekInMonth(3, DayOfWeek.WEDNESDAY));</p>
<p>        System.out.println(localDate);<br />
    }<br />
}<br />

SUBSCRIBE/FOLLOW US