scala - parsing milliseconds time data -
i tried parsing time string time data, having problem parsing millisecond part. know how this?
val format = new simpledateformat( "yyyy-mm-dd aa hh:mm:ss.ssssss") format.setlenient( false) try(new timestamp(format.parse( "2015-11-13 6:27:26.933000").gettime)) match { case success(t) => some(t) case failure(_) => // cannot convert. error here }
- you use
aa
don't provide in actual input, causes failure s
stands milliseconds, , ranges between 0 , 999, , provided bigger number, causes failure- you asked
hh
, gave in input single digit, doesn't cause failure.
and working example:
val format = new simpledateformat( "yyyy-mm-dd hh:mm:ss.sss") format.setlenient( false) try(new timestamp(format.parse("2015-11-13 pm 06:27:26.933").gettime)) match { case success(t) => println(t.gettime) case failure(err) => println(err) }
Comments
Post a Comment