?
Solved

How to get the date and time in java?

Posted on 2011-03-16
3
Medium Priority
?
250 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 1000 total points
ID: 35151963
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
ID: 35152010
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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month14 days, 9 hours left to enroll

840 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