How to implement isWeekend()?

I would like to ask. I've a date format like 2016-09-07 00:00:00 I want to construct a method in java which will validate this date as weekend or not. (based on my calendar)

The methods are something like this.

 public boolean isWeekend(java.util.Date dt){
 </span><span class="com" style="margin: 0px; padding: 0px; border: 0px; color: rgb(133, 140, 147);">//process here</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; color: rgb(48, 51, 54);">
 </span><span class="kwd" style="margin: 0px; padding: 0px; border: 0px; color: rgb(16, 16, 148);">return</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; color: rgb(48, 51, 54);"> </span><span class="kwd" style="margin: 0px; padding: 0px; border: 0px; color: rgb(16, 16, 148);">true</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; color: rgb(48, 51, 54);">;</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; color: rgb(48, 51, 54);">    

}
What should i code to validate the date given?

Thanks.

Hi Billel,


Thank you for writing to us again.

You may use isDayWorking() function of calendar class to check the weekday status. Please give try to the following sample code and share the feedback.
Project proj = new Project(“sample.mpp”);
java.util.Calendar calTimeStart = java.util.Calendar.getInstance();
//calTimeStart.set(2016,8,7,0,0,0); //Sep 7, 2016 Wed 
calTimeStart.set(2016,8,10,0,0,0); //Sep 10, 2016 Sat 

if(proj.getCalendars().getByUid(1).isDayWorking(calTimeStart.getTime()))
    System.out.println(“Its a working day”);
else 
    System.out.println(“Its weekend”);