https://github.com/rededge967/fest-countdown
Holiday countdown programs for Christmas, New year and Halloween with Java
https://github.com/rededge967/fest-countdown
countdown holiday holiday-countdown java
Last synced: 7 months ago
JSON representation
Holiday countdown programs for Christmas, New year and Halloween with Java
- Host: GitHub
- URL: https://github.com/rededge967/fest-countdown
- Owner: RedEdge967
- Created: 2021-11-28T09:06:43.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-12-01T12:55:23.000Z (almost 4 years ago)
- Last Synced: 2025-01-19T12:52:14.710Z (9 months ago)
- Topics: countdown, holiday, holiday-countdown, java
- Language: Java
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# fest-countdown
#### Hello everyone! Are you interested in holidays? so am I. In this repo you can find some holiday countdown programs made with java. This programs can calculate the months and days for the following holidays.
- Christmas
- New year
- Halloween## How to?
Go to the `releases` of this repo and `download` it or copy the codes, go to a online `java-compiler` and paste it and run.
#### Codes are below 👇
### Christmas ❄️
```java
import java.time.LocalDate;// importing LocalDate class
import java.time.Month;// importing Month class
import java.time.Period;// importing Period class
import java.time.temporal.ChronoUnit;// importing ChronoUnit class
public class aaa {
public static void main(String[] args) {
LocalDate today = LocalDate.now();//getting current date
LocalDate ChristmasDay = LocalDate.of(2020, Month.DECEMBER, 25);// setting Christmass day
LocalDate nextXmas = ChristmasDay.withYear(today.getYear());// Next year Christmas
//Add 1 if Christmas has past this year
if (nextXmas.isBefore(today) || nextXmas.isEqual(today)) {
nextXmas = nextXmas.plusYears(1);
}
Period p = Period.between(today, nextXmas);
long p2 = ChronoUnit.DAYS.between(today, nextXmas);// nanoseconds in days till Christmas
System.out.println("There are " + p.getMonths() + " months, and " +
p.getDays() + " days until Christmas! (" +
p2 + " total)");
}
}
```
### New year 🎆
```java
import java.time.LocalDate;// importing LocalDate class
import java.time.Month;// importing Month class
import java.time.Period;// importing Period class
import java.time.temporal.ChronoUnit;// importing ChronoUnit class
public class aaa {
public static void main(String[] args) {
LocalDate today = LocalDate.now();//getting current date
LocalDate ChristmasDay = LocalDate.of(2020, Month.JANUARY, 01);// setting Christmass day
LocalDate nextXmas = ChristmasDay.withYear(today.getYear());// Next year Christmas
//Add 1 if Christmas has past this year
if (nextXmas.isBefore(today) || nextXmas.isEqual(today)) {
nextXmas = nextXmas.plusYears(1);
}
Period p = Period.between(today, nextXmas);
long p2 = ChronoUnit.DAYS.between(today, nextXmas);// nanoseconds in days till Christmas
System.out.println("There are " + p.getMonths() + " months, and " +
p.getDays() + " days until New year! (" +
p2 + " total)");
}
}
```
### Halloween 🍬
```java
import java.time.LocalDate;// importing LocalDate class
import java.time.Month;// importing Month class
import java.time.Period;// importing Period class
import java.time.temporal.ChronoUnit;// importing ChronoUnit class
public class aaa {
public static void main(String[] args) {
LocalDate today = LocalDate.now();//getting current date
LocalDate ChristmasDay = LocalDate.of(2020, Month.OCTOBER, 31);// setting Christmass day
LocalDate nextXmas = ChristmasDay.withYear(today.getYear());// Next year Christmas
//Add 1 if Christmas has past this year
if (nextXmas.isBefore(today) || nextXmas.isEqual(today)) {
nextXmas = nextXmas.plusYears(1);
}
Period p = Period.between(today, nextXmas);
long p2 = ChronoUnit.DAYS.between(today, nextXmas);// nanoseconds in days till Christmas
System.out.println("There are " + p.getMonths() + " months, and " +
p.getDays() + " days until Halloween! (" +
p2 + " total)");
}
}
```
> ### Don't forget to give a star... 🌟