Support Unix time format
AutoRest modeler supports a Unix date time format for int type. It lets a spec specify that a date needs to be sent as the number of seconds since Unix epoch time to the server. This is implemented in some languages, but requires serialization/deserialization code in some remaining languages.
This issue: https://github.com/Azure/autorest/issues/909 tracked the changes needed in the modeler. It was implemented in C# in this PR: https://github.com/Azure/autorest/pull/948
@jianghaolu I've assigned this to you for the Java implementation, but please re-assign to someone else if they're going to end up doing this work.
@jianghaolu there are issues with the solution when generating the code. getDateTime() method and Long class are missing:
public DateTime created() {
if (this.created == null) {
return null;
}
return this.created.getDateTime();
}
public Attributes withExpires(DateTime expires) {
this.expires = new Long(expires);
return this;
}
@jianghaolu thanks for fixing the previous issue. With the new solution the issue is null pointers. For example, this will throw java.lang.NullPointerException if expires is null:
public Attributes withExpires(DateTime expires) {
this.expires = expires.toDateTime(DateTimeZone.UTC).getMillis() / 1000;
return this;
}
Fix in https://github.com/Azure/autorest/pull/1284.