0

please i want to convert string to datetime by using jsp and i hope to any one replay

Example

String s="mm/dd/yyyy"

to

Datetime s1=s:?: :?: :?: :?: :?:

4
Contributors
4
Replies
5
Views
10 Years
Discussion Span
Last Post by rgtaylor
0

use
DateTime.parseDateTime(String)
or
DateTime.parseDate(String)

Each will return a DateTime object from a string in a standard format... if it doesn't inderstand the string it will throw a NumberFormatException

Peace,

0

You can use SimpleDateFormat class also.
String s="mm/dd/yyyy"

Date d = new Date();
SimpleDateFormat st = new SimpleDateFormat(s);
st.format(d);

0

You guys are missing the point, this person wants to go other way... they have a date, in a string they want to get the timestamp object that equals that date.... not the other way around...

SimpleDateFormat reads a date format from a string that contains formatting codes and then allows you to turn a date object into a string that displays in the format you setup... great but that is "Date to String"
They want to go from "String to DateTime"... That is quite a bit different...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.