How to convert a date to dd.MM.yyyy format in Java? -


this question has answer here:

how can convert date(mon jan 12 00:00:00 ist 2015) in format mm.dd.yyyy or dd.mm.yyyy?

i tried using below approach

    string datestr = "mon jan 12 00:00:00 ist 2015";      dateformat formatter = new simpledateformat("e mmm dd hh:mm:ss z yyyy");     system.out.println(formatter.format(datestr)); 

but got,

exception in thread "main" java.lang.illegalargumentexception:  cannot format given object date 

we using jdk6?

you have parse string date format date

string datestr = "mon jan 12 00:00:00 ist 2015";  dateformat formatter = new simpledateformat("e mmm dd hh:mm:ss z yyyy"); dateformat formatter1 = new simpledateformat("dd.mm.yyyy"); system.out.println(formatter1.format(formatter.parse(datestr))); 

demo


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -