if (usage == null) {
throw new CannotTranslateException("usage is missing");
}
final UsedAndReservedTime_Type ret = new UsedAndReservedTime_Type();
// exceeds 6 million years of usage?
final long reserved = usage.getReservedMinutes();
if (reserved > Integer.MAX_VALUE) {
throw new CannotTranslateException(
"Reserved time exceeds maximum integer size");
}
ret.setReservedTime(CommonUtil.minutesToDuration((int)reserved));
// exceeds 6 million years of usage?
final long elapsed = usage.getElapsedMinutes();
if (elapsed > Integer.MAX_VALUE) {
throw new CannotTranslateException(
"Elapsed time exceeds maximum integer size");
}
ret.setUsedTime(CommonUtil.minutesToDuration((int)elapsed));
return ret;
}