How to convert a date to dd.MM.yyyy format in Java? -
this question has answer here:
- converting date format 5 answers
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)));
Comments
Post a Comment