date - Conversion of DateTime in java -
this question has answer here:
one of fields of json string
contains time in following format: 2017-04-04t20:22:33
or 2017-04-07t12:21:10.0355277+00:00
. task convert more simple representation this: "apr-4 20:22". thinking about creating simpledateformat
, doesn't seem work such datetime format.
is there effective way handle task?
try this
string date="2017-04-04t20:22:33"; simpledateformat sdf = new simpledateformat("yyyy-mm-dd't'hh:mm:ss"); simpledateformat sdf1 = new simpledateformat("mmm-dd hh:mm"); try{ date parsedate = sdf.parse(date); string output = sdf1.format(parsedate); }catch(exception e) { }
Comments
Post a Comment