• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to get Current Time in Java....  RSS feed

 
Maya sekar
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I need to get the current time (as displayed on the system) in my program and schedule a task to run at a particular time everyday.... I heard in java the time is displayed by UTC Time.... Will it not be possible to get the local time?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maya sekar wrote:I heard in java the time is displayed by UTC Time....

That's not true. You can display the time in any timezone you like.

You get the current time by simply creating a new java.util.Date object. You can format it as you like with a SimpleDateFormat. By default it will use the local timezone of your computer, but you can tell the SimpleDateFormat object to display it in any other timezone.
 
Maya sekar
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jesper,

Thank you loads for your time and response..... That is exactly what I was looking for....
Thanks again....
Have a nice day
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!