Merge "Use month in the range 1-12 for 3GPP2 SMS Time Stamp instead"

This commit is contained in:
Amit Mahajan
2020-02-18 18:40:30 +00:00
committed by Gerrit Code Review

View File

@@ -248,10 +248,10 @@ public final class BearerData {
public int hour; public int hour;
public int monthDay; public int monthDay;
/** Month [0-11] */ /** Month in the range 1(Jan) - 12(Dec). */
public int month; public int monthOrdinal;
/** Full year. For example, 1970. */ /** Full year in the range 1996 - 2095. */
public int year; public int year;
private ZoneId mZoneId; private ZoneId mZoneId;
@@ -269,7 +269,7 @@ public final class BearerData {
ts.year = year >= 96 ? year + 1900 : year + 2000; ts.year = year >= 96 ? year + 1900 : year + 2000;
int month = IccUtils.cdmaBcdByteToInt(data[1]); int month = IccUtils.cdmaBcdByteToInt(data[1]);
if (month < 1 || month > 12) return null; if (month < 1 || month > 12) return null;
ts.month = month - 1; ts.monthOrdinal = month;
int day = IccUtils.cdmaBcdByteToInt(data[2]); int day = IccUtils.cdmaBcdByteToInt(data[2]);
if (day < 1 || day > 31) return null; if (day < 1 || day > 31) return null;
ts.monthDay = day; ts.monthDay = day;
@@ -292,7 +292,7 @@ public final class BearerData {
int year = localDateTime.getYear(); int year = localDateTime.getYear();
if (year < 1996 || year > 2095) return null; if (year < 1996 || year > 2095) return null;
ts.year = year; ts.year = year;
ts.month = localDateTime.getMonthValue(); ts.monthOrdinal = localDateTime.getMonthValue();
ts.monthDay = localDateTime.getDayOfMonth(); ts.monthDay = localDateTime.getDayOfMonth();
ts.hour = localDateTime.getHour(); ts.hour = localDateTime.getHour();
ts.minute = localDateTime.getMinute(); ts.minute = localDateTime.getMinute();
@@ -304,7 +304,7 @@ public final class BearerData {
int year = this.year % 100; // 00 - 99 int year = this.year % 100; // 00 - 99
ByteArrayOutputStream outStream = new ByteArrayOutputStream(6); ByteArrayOutputStream outStream = new ByteArrayOutputStream(6);
outStream.write((((year / 10) & 0x0F) << 4) | ((year % 10) & 0x0F)); outStream.write((((year / 10) & 0x0F) << 4) | ((year % 10) & 0x0F));
outStream.write((((month / 10) << 4) & 0xF0) | ((month % 10) & 0x0F)); outStream.write((((monthOrdinal / 10) << 4) & 0xF0) | ((monthOrdinal % 10) & 0x0F));
outStream.write((((monthDay / 10) << 4) & 0xF0) | ((monthDay % 10) & 0x0F)); outStream.write((((monthDay / 10) << 4) & 0xF0) | ((monthDay % 10) & 0x0F));
outStream.write((((hour / 10) << 4) & 0xF0) | ((hour % 10) & 0x0F)); outStream.write((((hour / 10) << 4) & 0xF0) | ((hour % 10) & 0x0F));
outStream.write((((minute / 10) << 4) & 0xF0) | ((minute % 10) & 0x0F)); outStream.write((((minute / 10) << 4) & 0xF0) | ((minute % 10) & 0x0F));
@@ -314,7 +314,7 @@ public final class BearerData {
public long toMillis() { public long toMillis() {
LocalDateTime localDateTime = LocalDateTime localDateTime =
LocalDateTime.of(year, month + 1, monthDay, hour, minute, second); LocalDateTime.of(year, monthOrdinal, monthDay, hour, minute, second);
Instant instant = localDateTime.toInstant(mZoneId.getRules().getOffset(localDateTime)); Instant instant = localDateTime.toInstant(mZoneId.getRules().getOffset(localDateTime));
return instant.toEpochMilli(); return instant.toEpochMilli();
} }
@@ -325,7 +325,7 @@ public final class BearerData {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("TimeStamp "); builder.append("TimeStamp ");
builder.append("{ year=" + year); builder.append("{ year=" + year);
builder.append(", month=" + month); builder.append(", month=" + monthOrdinal);
builder.append(", day=" + monthDay); builder.append(", day=" + monthDay);
builder.append(", hour=" + hour); builder.append(", hour=" + hour);
builder.append(", minute=" + minute); builder.append(", minute=" + minute);