I have an xml with time as
<Opened date="2012-09-13T18:30:34+05:30" Lang_Code="ENG"></Opened>
I need to represent it in proto3 format and ship the generated java classes. what data type to use? I tried google.protobuf.Timestamp but that does not fit the bill.
syntax = "proto3";
message Opened{
<what data type?> date =1;
string lang_code=2;
}
You might want to at least consider using the DateTime
message in google/type/datetime.proto - that repo is the one we (Google) use for our public API protos, including supporting types like DateTime
.
You'd probably want to document and validate that:
year
value would never be 0hour
value would never be 24seconds
value would never be 60 (unless you actually plan on supporting leap seconds)time_offset
oneof will always be populated via utc_offset
Of course, you can create your own proto with similar information, should you wish. There's no out-of-the-box message that includes what you need, so you'll need to use some kind of message, unless you want to just leave it as a string (which I wouldn't recommend).