saif
saif

Reputation: 43

Countdown application for java

iam a newbie in java and i have a task at hand to make a simple application in java for countdown.

like for ex in that application if i enter the current date it should display how much time is left for christmas or a newyear or any religious occassion ...............

and it should display the result in the format like years/months/days/hours/minutes and seconds........

plz help me for how to go with this...............

thanks in advance.

Upvotes: 0

Views: 463

Answers (3)

Andreas Dolk
Andreas Dolk

Reputation: 114767

The task is pretty straightforward. You need solutions for the steps

  1. Capture user input (Scanner class, includes presenting a message to the user
  2. Convert user input to a Date (includes rejecting invalid data)
  3. Calculate the 'distance' to another date (like christmas)
  4. Print the result (convert the Date distance to a readable message)

1., 2. and 4. can be done in the main method, for 3. I'd implement a separate method. like private static Date getDistance(Date earlier, Date later)

Upvotes: 0

Boris Pavlović
Boris Pavlović

Reputation: 64632

First start with a hello world tutorial. After that move on joda time library since it's much more usable than the standard Java time/date/calendar. If you need further help do not hesitate to post a question here.

Upvotes: 2

Redlab
Redlab

Reputation: 3118

How to go?

Let the user input the date, Calculate the difference from the inputted date to the occasions-dates and output them

The dates of the occassions you can put in a properties file that you read on launching the application

See Formatting dates for formatting

Upvotes: 0

Related Questions