Solved

Convert Datetime(yyy-MM-dd'T'hh:mm:ss) to date(mm/dd/yy) in java

Posted on 2009-05-06
7
1,249 Views
Last Modified: 2013-11-23
Hi
i need to  Convert Datetime(yyy-MM-dd'T'hh:mm:ss) to date(mm/dd/yy) in java

thanks
0
Comment
Question by:ursreenu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 24312772
Try
String d = new SimpleDateFormat("MM/dd/yy").format(new SimpleDateFormat("yyy-MM-dd'T'hh:mm:ss").parse(date));

Open in new window

0
 
LVL 92

Accepted Solution

by:
objects earned 125 total points
ID: 24312781
parse the date (using source format)

http://helpdesk.objects.com.au/java/how-do-i-parse-a-java-string-that-specifies-a-date

then format it (using the target format)

http://helpdesk.objects.com.au/java/how-do-i-format-a-date-as-a-string

let me know if you need my help

0
 
LVL 92

Expert Comment

by:objects
ID: 24312788
> String d = new SimpleDateFormat("MM/dd/yy").format(new SimpleDateFormat("yyy-MM-dd'T'hh:mm:ss").parse(date));

just as i suggested :) though I wouldn't do it in one line. you'll get poor performance with that. Instead create two DateFormat's and reuse them

0
What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

 
LVL 86

Expert Comment

by:CEHJ
ID: 24312822
>>parse the date (using source format)

Just as i suggested. ursreenu, i assume you know how to save instances of classes if you want to to reuse them ;-)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24312844
If you want UTC in your target format, set the TimeZone on that DateFormat:
d2.setTimeZone(TimeZone.getTimeZone("UTC"));

Open in new window

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24313294
ursreenu, can you explain why you accepted an answer that is just a copy of mine?
0
 
LVL 92

Expert Comment

by:objects
ID: 24313335
Let me know if you need any further help :)

0

Featured Post

Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

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 last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
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:

726 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