Created
January 11, 2016 20:34
-
-
Save jokamjohn/ebe10b01aa3ad1c2695a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.time.DayOfWeek; | |
| import java.time.LocalDate; | |
| import java.time.temporal.TemporalAdjusters; | |
| public class TemporalAdjustersExamples | |
| { | |
| public static void main( String[] args ) | |
| { | |
| /* using adjuster is possible to adjust a given date */ | |
| LocalDate now = LocalDate.now(); | |
| System.out.println( "now " + now ); | |
| DayOfWeek dayOfWeek = now.getDayOfWeek(); | |
| System.out.println( "day of week " + dayOfWeek ); | |
| LocalDate adjusted = now.with( TemporalAdjusters.lastDayOfMonth() ); | |
| System.out.println( "now with last day of month " + adjusted ); | |
| System.out.println( "now " + now ); | |
| System.out.println( "now with last friday in month " | |
| + now.with( TemporalAdjusters.lastInMonth( DayOfWeek.FRIDAY ) ) ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment