File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes how to covert string to date object?. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to covert string to date object?." Watch "how to covert string to date object?." New topic
Author

how to covert string to date object?.

pdayakar reddy
Greenhorn

Joined: Dec 20, 2010
Posts: 5
hello frds.
i want codes of these problems
1)How to convert string to date object?.
2)How to get date, month,year value from the current date?.
3)How to calculate difference in days between two days?.
and more related dates and days years codes........
S. Nitesh
Ranch Hand

Joined: Jan 15, 2010
Posts: 36
    
    1

Its NotACodeMill.
ShowSomeEffort.

For your requirement you can refer SimpleDateFormat from java api.
Minni Sharma
Greenhorn

Joined: Mar 03, 2010
Posts: 16

1) DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
Date today = df.parse("20/12/2005");
System.out.println("Today = " + df.format(today));

2) today.getday
today.getHour ....etc
pdayakar reddy
Greenhorn

Joined: Dec 20, 2010
Posts: 5
Nitesh Sakargayan wrote:Its NotACodeMill.
ShowSomeEffort.

For your requirement you can refer SimpleDateFormat from java api.

thanks alot
pdayakar reddy
Greenhorn

Joined: Dec 20, 2010
Posts: 5
Minni Sharma wrote:
1) DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
Date today = df.parse("20/12/2005");
System.out.println("Today = " + df.format(today));

2) today.getday
today.getHour ....etc



Thaks alot dude.
S. Nitesh
Ranch Hand

Joined: Jan 15, 2010
Posts: 36
    
    1

pdayakar, You are welcome.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
Please read what it says on the contents page for "beginning Java"
We're all here to learn, so when responding to others, please focus on helping them discover their own solutions, instead of simply providing answers.
Minni Sharma, please avoid giving straight answers to somebody like that. By so doing, you are depriving them of an opportunity to learn.
Aditya Jha
Ranch Hand

Joined: Aug 25, 2003
Posts: 227

Campbell is right. Let's try and cultivate a culture of learning.

For example, if pdayakar simply copies Minni's code, and finds that the following is not throwing any exceptions, he'll be puzzled:



@pdayakar A quick glance to JavaDoc for SimpleDateFormat is definitely recommended.
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3097
    
  33

And there's JavaDatesFaq which have more than enough information


Mohamed Sanaulla | My Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to covert string to date object?.