Skip to main content
Post Closed as "Duplicate" by Basil Bourque, Dennis Meng, Zsolt Botykai, Blackbelt, Abimaran Kugathasan
code formatting and 'java' tag added
Source Link
MikeM
  • 27.5k
  • 4
  • 67
  • 80

I have a string String startDate = "06/27/2007"; now

String startDate = "06/27/2007";

now i have to get Date object. My DateObject should be the same value as of startDate.

I am doing like this DateFormat df = new SimpleDateFormat("mm/dd/yyyy"); Date startDate = df.parse(startDate);

DateFormat df = new SimpleDateFormat("mm/dd/yyyy");
Date startDate = df.parse(startDate);

But the output is in format Jan 27 00:06:00 PST 2007.

Jan 27 00:06:00 PST 2007.

I have a string String startDate = "06/27/2007"; now i have to get Date object. My DateObject should be the same value as of startDate.

I am doing like this DateFormat df = new SimpleDateFormat("mm/dd/yyyy"); Date startDate = df.parse(startDate);

But the output is in format Jan 27 00:06:00 PST 2007.

I have a string

String startDate = "06/27/2007";

now i have to get Date object. My DateObject should be the same value as of startDate.

I am doing like this

DateFormat df = new SimpleDateFormat("mm/dd/yyyy");
Date startDate = df.parse(startDate);

But the output is in format

Jan 27 00:06:00 PST 2007.

Source Link
user755043
  • 1.7k
  • 3
  • 12
  • 12

how to convert java string to Date object

I have a string String startDate = "06/27/2007"; now i have to get Date object. My DateObject should be the same value as of startDate.

I am doing like this DateFormat df = new SimpleDateFormat("mm/dd/yyyy"); Date startDate = df.parse(startDate);

But the output is in format Jan 27 00:06:00 PST 2007.