String to date conversion in java
posted 17 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I have my date in string format and I want to convert it into date format. I also tried toDate(String) function. But it is not giving result. And I also tried following code:
SimpleDateFormat formatter=new SimpleDateFormat(text3);
java.sql.Date effect_from=new java.sql.Date( formatter.parse(text3).getTime());
java.sql.Date end_on = new java.sql.Date(formatter.parse(text3).getTime());
In above code when I try to print 'effect_from'it prints any random date.
So please tell me solution.
SimpleDateFormat formatter=new SimpleDateFormat(text3);
java.sql.Date effect_from=new java.sql.Date( formatter.parse(text3).getTime());
java.sql.Date end_on = new java.sql.Date(formatter.parse(text3).getTime());
In above code when I try to print 'effect_from'it prints any random date.
So please tell me solution.
posted 17 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Welcome to JavaRanch.
The SimpleDateFormat constructor doesn't take the text to be parsed as argument, it takes the format description as argument. See the javadocs of the SimpleDateFormat class for a lengthy explanation of the available formats.
The SimpleDateFormat constructor doesn't take the text to be parsed as argument, it takes the format description as argument. See the javadocs of the SimpleDateFormat class for a lengthy explanation of the available formats.
posted 17 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
SimpleDateFomat line is wrong...
instead of passing actuall string to SimpleDateFormat,it should pass the pattern..
eg :-
instead of passing actuall string to SimpleDateFormat,it should pass the pattern..
eg :-
posted 17 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Please take the time to choose the correct forum for your posts. This forum is for questions on HTML.
This post has been moved to a more appropriate forum.
This post has been moved to a more appropriate forum.
Amit Y Desai
Ranch Hand
Posts: 35
posted 17 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
hi Bear Bibeault ,
i thing this post belongs to correct topic..as string to date conversion comes under "java in general"...
i thing this post belongs to correct topic..as string to date conversion comes under "java in general"...
posted 17 years ago
Note that "mm/dd/yyyy" means most likely not what you think it means. "mm" is minutes, not months. Use "MM" for months. See the API documentation of class SimpleDateFormat for documentation about the format string.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Originally posted by Amit Y Desai:
SimpleDateFomat line is wrong...
instead of passing actuall string to SimpleDateFormat,it should pass the pattern..
eg :-
Note that "mm/dd/yyyy" means most likely not what you think it means. "mm" is minutes, not months. Use "MM" for months. See the API documentation of class SimpleDateFormat for documentation about the format string.
Ulf Dittmer
Rancher
Posts: 43081
77
posted 17 years ago
It was originally posted in the HTML forum, here, that's why that post is there.
You will see many such messages as unfortunately it's a common phenomenon that people post topics into unrelated forums.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Originally posted by Amit Y Desai:
i thing this post belongs to correct topic..as string to date conversion comes under "java in general"...
It was originally posted in the HTML forum, here, that's why that post is there.
You will see many such messages as unfortunately it's a common phenomenon that people post topics into unrelated forums.
posted 17 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Please find the code in the below URL
http://developerparadise.com/devworld/Faqs/2007/Java/3Collection/JavaCollectionFaqs_3_Integerate.php#q0
[ February 22, 2008: Message edited by: vikram veera ]
[ February 22, 2008: Message edited by: vikram veera ]
http://developerparadise.com/devworld/Faqs/2007/Java/3Collection/JavaCollectionFaqs_3_Integerate.php#q0
[ February 22, 2008: Message edited by: vikram veera ]
[ February 22, 2008: Message edited by: vikram veera ]
| We don't have time to be charming! Quick, read this tiny ad: The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |










