Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-23-2007, 08:26 PM
Member
 
Join Date: Jul 2007
Posts: 41
tommy is on a distinguished road
problems with Date format
I want the Date to be in this format
05-07-2007,
But I get
5-7-2007 and I don't want it.

how can I do that? ( 05-07-2007)

any suggestions?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-25-2007, 09:38 PM
Member
 
Join Date: Jul 2007
Posts: 55
Seemster is on a distinguished road
Use the SimpleDateFormat class.

try {
// Some examples
DateFormat formatter = new SimpleDateFormat("MM/dd/yy");
Date date = (Date)formatter.parse("01/29/02");

formatter = new SimpleDateFormat("dd-MMM-yy");
date = (Date)formatter.parse("29-Jan-02");

// Parse a date and time; see also
// e317 Parsing the Time Using a Custom Format
formatter = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss");
date = (Date)formatter.parse("2002.01.29.08.36.33");

formatter = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss Z");
date = (Date)formatter.parse("Tue, 29 Jan 2002 22:14:02 -0500");
} catch (ParseException e) {
}
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between current date and anothe date vijay balusamy New To Java 1 04-16-2008 05:15 PM
How to format the date in particular pattern Java Tip java.text 0 04-04-2008 03:35 PM
How to format the date in particular pattern JavaBean Java Tips 0 10-04-2007 10:28 PM
Date format display in CSV file after exporting latha Advanced Java 0 08-03-2007 09:09 AM
Code format Eric XML 1 07-06-2007 08:44 AM


All times are GMT +3. The time now is 06:19 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org