java - JsonFormat annotation to parse two date type -


i have problem, want parse different type of date string timestamp.

i used

@jsonformat(shape=jsonformat.shape.string, pattern ="dd-mmm-yyyy hh:mm:ss.sss       z",timezone="ist") private timestamp validuptodate; 

and parsing ok when milisecond value given after second, if provide "16-dec-2014 15:20:30 ist" type of date, getting below exception ::

failed parse date value '15-aug-2019 19:30:00 ist' (format: "dd-mmm-yyyy hh:mm:ss.sss z"): unparseable date: "15-aug-2019 19:30:00 ist" 

but if provide "16-dec-2014 15:20:30.000 ist" , no issues. dont want mention milisecond value if not present.

i tried provide 2 pattern value llike

@jsonformat(shape=jsonformat.shape.string, pattern ={"dd-mmm-yyyy hh:mm:ss z","dd-mmm-yyyy hh:mm:ss.sss z"} ,timezone="ist") 

but compilation error happens. tried using different combination, no hope. please help. lot.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -