SavantMohan
SavantMohan

Reputation: 35

Date format for REST API

I want to encode the date format to send the date through my REST API request. I have sample response as createDate=1449092965474 I don't know which format it is. Kindly help me decoding this date format.

Upvotes: 1

Views: 10939

Answers (4)

K Kumar
K Kumar

Reputation: 141

try this

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")

Upvotes: 0

Kaushik
Kaushik

Reputation: 2090

Server Side (C#)

Before Sending the date from your API.

Convert the date to a string.

like this .

string YourNewDateObj = YourDateObj.toString("yyyy-MM-dd HH:mm:ss");

Client Side

new Date(1449092965474)

This is give you response.

Upvotes: 0

Daniel Bauer
Daniel Bauer

Reputation: 168

It's a javascript date in milliseconds since 1970. (Reference: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Date)

In this case:

new Date(1449092965474)

is

Wed Dec 02 2015 22:49:25 GMT+0100

I would recommend using ISO 8601 Format in your REST API.

Upvotes: 3

Foxy
Foxy

Reputation: 416

Dates written as numbers, specifies the number of milliseconds since January 1, 1970, 00:00:00. So if you convert it to normal date it will be Wed Dec 02 2015 16:49:25 GMT-0500 (Eastern Standard Time).

Upvotes: 0

Related Questions