[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2009-05-06
7
Medium Priority
?
1,269 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 375 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 does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
A solution for Fortify Path Manipulation.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

656 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