I need to pass a string in this format: "yyyy-mm-dd + HH: mm: ss" (where the "+" should be a space) for a webservice from a Java Date object. How can I do this?
I need to pass a string in this format: "yyyy-mm-dd + HH: mm: ss" (where the "+" should be a space) for a webservice from a Java Date object. How can I do this?
You can do with SimpleDateFormat
, but if you are passing the date to be formatted in "dd / MM / yyyy" mode and are trying to move to a webservice, SimpleDateFormat
will not be able to format. I advise you to change the "/" to "-".
You can use SimpleDateFormat to do this.
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date();
String formatedDate = dateFormat.format( date );
You can read more about it here: link