开发者

Countdown application for java

开发者 https://www.devze.com 2023-01-06 17:58 出处:网络
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

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/minut开发者_如何学Goes and seconds........

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

thanks in advance.


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.


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


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)

0

精彩评论

暂无评论...
验证码 换一张
取 消