?
Solved

Convert String to Date

Posted on 2003-03-20
7
Medium Priority
?
260 Views
Last Modified: 2010-04-17
String txtDateOfBirth = request.getParameter("txtDateOfBirth");

I need to change string into date so as I can place in a bean value which has datatype of date
private Date dateOfBirth;




0
Comment
Question by:calis
[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
7 Comments
 
LVL 3

Expert Comment

by:Genetic_Wolf
ID: 8174493
To avoid any mistake from the computer about the month and day, use

use the Date serail Function

MyString$ = DateSerial(year, month, day)

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsfctdateserial.asp

0
 
LVL 3

Expert Comment

by:Genetic_Wolf
ID: 8174541
Grrr I answer to 10 quesiton today and none of them have been add to my Profiles...

Anyway, I made a mistake when I answer to you, I should have said:

First, Extract Year, Month and Day from your String.
then,

use the dateserial function

dim MyDate as date

MyDate = DateSerial(year, month, day)

This will avoid the computer to mistake Day for Month from any other possible type of conversion.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsfctdateserial.asp

0
 

Author Comment

by:calis
ID: 8174563
Sorry I am probably in wrong section I am programing Java
0
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
LVL 1

Expert Comment

by:Intern
ID: 8175670
calis:
>>Sorry I am probably in wrong section I am programing Java

You should go to Community Support and post a question there asking them to delete this question and refund your points.  Then you can repost this question in the JAVA area.
0
 

Accepted Solution

by:
jaisuri earned 400 total points
ID: 8177874
There are different ways of doing this.
1. Use the java.util.Calendar class. COnsidering that you know the format of the data and can parse it, you can use

  Calendar cal = Calendar.getInstance();

  cal.set(Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day));

   Date dt = cal.getTime();

2. Use java.text.DateFormat or java.text.SimpleDateFormat which is a subclass of DateFormat.

  You can use DateFormat.parse(String date) to get a java.util.Date object.




0
 

Expert Comment

by:CleanupPing
ID: 9446947
calis:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Simple Linear Regression
Suggested Courses

770 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