Solved

How to get the date and time in java?

Posted on 2011-03-16
3
240 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
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
 
LVL 92

Expert Comment

by:objects
ID: 35152150
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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 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…
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.

839 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