java - How to map timestamp to date in Object mapper -


right mapping timestamp date using object mapper, turning date object's date this, if timestamp 1359657000, it's date should 01/31/2013, showing me date 01/31/1970, didn't issue approach.

public class abcd{     private date year  } 

and json

{ "data": { "fromdate": 1335810600" } } 

and when map object mapper

objectmapper mapper =new mapper(); mapper.readvalue(data,abcd.class); 

now value of year coming 31st dec 1970, although should coming 31st dec 2013

not sure if understand issue, in of situations don't want deal timestamps:

mapper.disable(serializationfeature.write_dates_as_timestamps); 

then can define format of date:

@jsonformat(shape = jsonformat.shape.string, pattern = "dd-mm-yyyy") public date date; 

Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -