Saturday, June 24, 2017

How to pass date type parameter in a restful service

In certain use case, we might need to pass date type parameter from service consumer to service provider.
But date as a object is not allowed to transfer via http.

The are only 2 additional steps to resolve this problem
1. at consumer side, convert the date object to long value
2. at provider side, convert the long value back to date object.

in Javascript / Play / SpringBoot consumer, convert the date object to long value

new Date().getTime();



in Play / SpringBoot provider, convert the long date value to date object.

new Date( dateValueInLong );




Done!!



LinkWithin

Related Posts Plugin for WordPress, Blogger...