# New Year Countdown Timer (to 2024)

**URL:** <https://discourse.processing.org/t/new-year-countdown-timer-to-2024/43597>\
**Category:** Gallery\
**Created:** [December 31, 2023, 10:02pm UTC](https://discourse.processing.org/t/new-year-countdown-timer-to-2024/43597 "2023-12-31T22:02:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [December 31, 2023, 10:02pm UTC](https://discourse.processing.org/t/new-year-countdown-timer-to-2024/43597/1 "2023-12-31T22:02:01Z")

</div>

Happy New Year Folks!

New Year Countdown Timer:

```auto
// Time Elapsed using System.currentTimeMillis()
// v1.1.1
// GLV 2023-12-31

// https://docs.oracle.com/javase/8/docs/api/java/util/GregorianCalendar.html
// https://www.timeanddate.com/counters/firstnewyear.html

import java.time.*;
import java.util.*;

long targetTime;
boolean flag;

void setup() 
  {
  size(1000, 200);
  
  textSize(96+16);
  textAlign(LEFT, CENTER);
  fill(255, 255, 0);
 
  //GregorianCalendar target = new GregorianCalendar(year, month-1, day, hour, minute, second);
  GregorianCalendar target = new GregorianCalendar(2024, 1-1, 1, 0, 0, 0); // New years day at 00:00:00
  
  targetTime = target.getTimeInMillis();
  //println(targetTime);
  
  textAlign(CENTER, CENTER);
  }

void draw() 
  {
  background(0);  
  
  long timeRem = targetTime - System.currentTimeMillis();
  
  int days = (int)(timeRem/(60*60*24*1000));
  int hrs = (int)(timeRem/(60*60*1000));
  int mins = (int)(timeRem/(60*1000));
  int secs = (int)(timeRem/1000);
  int ms = (int)(timeRem - secs*1000);
  
  if (timeRem < 1) flag = true;
  
  String timeString = nf(days, 3) +":"+ 
                      nf(hrs - days*24, 2) +":"+ 
                      nf(mins - hrs*60, 2) +":"+ 
                      nf(secs - mins*60, 2) +":"+ 
                      nf(ms, 3);  
  
  if (!flag)
    {
    text(timeString, width/2, height/2-15);
    println(timeString);  
    }
  else
    {
    String message = "Happy New Year!";
    fill(0, 255, 0);
    text(message, width/2, height/2-15);
    }
  }    

```

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/4/c/4c6a50cdc061c939ffdb78dc8c7f0218abfb6db2.png)

Modify code to countdown to 2025 New Years Day!

`*GregorianCalendar target = new GregorianCalendar(2025, 1-1, 1, 0, 0, 0);*`

`:)`
