Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
pawe84
Creator
Creator

tjava: find 1st Sunday of January and July

Hi everyone,

how I can get the date in tjava for the first Sunday of January and the first Sunday of July?

I need these dates in order to compare the current date.

Thanks for any hints.

Labels (3)
1 Reply
Anonymous
Not applicable

Hello,

You could try writing your own routine to work out the 1st Sunday.

For example

import java.time.temporal.TemporalAdjuster;

import java.time.temporal.TemporalAdjusters;

 

   public class GFG {

      public static void pring(int year, int month, int day)

      {

 

          // get TemporalAdjuster with

          // the first in month adjuster

          TemporalAdjuster temporalAdjuster

              = TemporalAdjusters.firstInMonth(

            DayOfWeek.SUNDAY);

 

          // using adjuster for local date time

          LocalDate localDate

              = LocalDate.of(year, month,day);

          LocalDate firstInMonth

              = localDate.with(temporalAdjuster);

 

          // print

          System.out.println(

              "First date in month having"

              + " sunday for localdate "

              + localDate + " is:"

              + firstInMonth);

      }

   }

 

Please have a look at my screenshots for details and let us know if it is OK with you.

0693p00000BAgpWAAT.png0693p00000BAgpHAAT.png0693p00000BAgpCAAT.pngBest regards

Sabrina