• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

how to covert string to date object?.

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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........
 
Ranch Hand
Posts: 36
1
VI Editor Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its NotACodeMill.
ShowSomeEffort.

For your requirement you can refer SimpleDateFormat from java api.
 
Greenhorn
Posts: 16
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Nitesh Sakargayan wrote:Its NotACodeMill.
ShowSomeEffort.

For your requirement you can refer SimpleDateFormat from java api.


thanks alot
 
pdayakar reddy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 36
1
VI Editor Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
pdayakar, You are welcome.
 
Marshal
Posts: 80128
417
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 227
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And there's JavaDatesFaq which have more than enough information
 
Hey! You're stepping on my hand! Help me tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic