0

I am having trouble getting this following date in java pojo, when I parse using below date using below format I am getting only

INPUT: 2012-05-07T12:46:16.611-0500


public static String formatDate(Date date) {
    return date == null ? null : 
                          FORMAT_YYYY_MM_DD_T_HH_MM_SS_DOTXXX.format(date);
}

OUTPUT: 2012-05-07T12:46:16.06

EXCPECTED: 2012-05-07T12:46:16.611-0500

How to write date format equivalent to ABOVE given date in java? to get full date

fuggerjaki61
  • 822
  • 1
  • 11
  • 24
Rocky4Ever
  • 828
  • 3
  • 12
  • 35
  • 2
    What is `FORMAT_YYYY_M_D_T_HH_MM_SS_DOTXXX`? – Arvind Kumar Avinash Feb 28 '20 at 19:09
  • Input and expected output are same. – kann Feb 28 '20 at 19:12
  • something like [how to convert UTC date-time into ISO 8601 format in Java?](https://stackoverflow.com/q/60451547/85421) ? – user85421 Feb 28 '20 at 19:15
  • 1
    Well, you have two `MM` in your format; the second should be `mm`. – Elliott Frisch Feb 28 '20 at 19:15
  • To get better (if any) help [edit] your question and include [mcve] (in short example which is minimal - without any unrelated things like GUI, reading data from user when example data can be provided in code; complete - so we could copy-paste it to our machines and run it without any modifications; reproducable - it should generate precisely same problem you are claiming in the question). – Pshemo Feb 28 '20 at 19:28
  • Don't use `Date`, that's obsolete. Use classes from `java.time` instead. – MC Emperor Feb 28 '20 at 22:55

0 Answers0