Solved

How to get the date and time in java?

Posted on 2011-03-16
3
234 Views
Last Modified: 2012-06-21
Hi,
How can I get the date and time in java in this format?

2011-01-28 10:49 EST

Thanks,
0
Comment
Question by:Tolgar
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 250 total points
Comment Utility
Try
String s = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm Z").format(new java.util.Date());

Open in new window

0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
Actually, make that
String s = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm z").format(new java.util.Date());
or
String s = String.format("%tF %<tR %<tZ", new java.util.Date());

Open in new window

0
 
LVL 92

Expert Comment

by:objects
Comment Utility
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now