0

I want to convert "yyyy'-'MM'-'dd HH':'mm':'ss'Z'" date format to "yyyy'-'MM'-'dd HH':'mm':'ss" in java.

i.e. i have a date like "22-11-2017 23:42:09:0" and i want to convert it into "22-Nov-2017 23:42:09".

MT0
  • 143,790
  • 11
  • 59
  • 117
  • Hey Buddy, Please read about [how to format dates in Java](https://stackoverflow.com/questions/4772425/change-date-format-in-a-java-string), then try to implement something for your problem. if after that you face some problem then post that. – Neeraj Jain Nov 22 '17 at 08:06
  • @MT0 my bad, I used my spacebar instead of the dash. Next time, I will pay more attention. Thanks to you. – F0XS Nov 22 '17 at 08:16

2 Answers2

0

If so urgent,

String newValue = oldValue.substring(0, oldValue.lastIndexOf(":"));

would be enough.

Sanders the Softwarer
  • 2,478
  • 1
  • 13
  • 28
0

Why don't you use to_date() function in oracle sql. You can also get the output of the query by doing :

select to_date(#your format#)
from dual
Sarthak
  • 1,076
  • 1
  • 12
  • 20