how to represent date type in apache thrift
date, thrift, types
Solution
I don't think there is a date representation on Thrift IDL. We use this notation for our projects.
typedef string Timestamp
then use that notation on subsequent model which needs a timestamp usage like this
struct blah{
/**
* TODO:list what notation this dateTime represents. eg ISO-8601
* or if its in the format like YYYY-mm-DD you mentioned.
*/
1:Timestamp dateTime;
}
String makes it easier to use JODA Operations
--EDIT--
I don't know what timestamp you intend to store. For instance if you want to calculate current instance a transaction has occurred and store it into that thrift object, you can do this with Joda.
String timestamp = new DateTime().toString("YYYY-MM-dd"); //2013-03-26 This will be string value generated. It will convert the current time to format you seek to output.
//Use the generated thrift object.
Blah newblah = new Blah();
blah.setDateTime(timestamp);
Problem
I'm developing a service using apache thrift and I need to define periods of time. Dates are significant (`YYYY-mm-dd`) and time should be totally omitted (`HH:ii:ss`). I couldn't find any specific date/datetime thrift data type so I'm thinking about two approaches: more complex ``` int year, int month, int day, ``` less complex but includes time of day part which I don't need. ``` int timestamp ``` Is there a common thrift approach to represent date(time) types?