-1

if user selected the start and end date of leave of someone then I must to get the sum of days of weekend : sum of "Sturday" and "Sunday" days

Ana
  • 29
  • 9
  • 1
    Without **any** library? Not even the JDK? – Kevin Anderson Jun 23 '18 at 22:14
  • It’s not perfectly clear, sorry. Did you mean the count of dates, or do you need each date? “Without any library”, does that mean “without any external library” or are built-in library classes forbidden too (like `java.util.ArrayList` and `java.time.LocalDate`)? – Ole V.V. Jun 23 '18 at 22:18
  • Where is your search and research effort? What have you tried? In what way did it fail? – Ole V.V. Jun 23 '18 at 22:21
  • Get all the dates, then, remove from that the dates that happen to be on weekends. (Seriously, what else were you thinking exactly?) – kumesana Jun 23 '18 at 22:23
  • I want to work with java without library and I mean by library ,like Joda time library or any other date and time library for Java – Ana Jun 25 '18 at 10:50

1 Answers1

0

You can use the DateTimeFormatter class docs here

When you're using the date format object to leave out the weekend you can check for weekends from the attribute "E" (Day number of week) which is returned as an Integer. (please see the link posted). It unclear what your goal here with the dates, But it seems you are having problems knowing when a certain day is a weekend or not so I hope this helps.

cheesey
  • 516
  • 7
  • 18
  • 2
    Please don’t teach the young ones to use the long outdated and notoriously troublesome `SimpleDateFormat` class. At least not as the first option. And not without any reservation. Today we have so much better in [`java.time`, the modern Java date and time API](https://docs.oracle.com/javase/tutorial/datetime/) and its `DateTimeFormatter`. – Ole V.V. Jun 23 '18 at 22:11
  • very true that was what I was looking for. I did a quick google search on the docs @OleV.V. Edited my answer to support that – cheesey Jun 23 '18 at 22:33