Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 06c9932b authored by William Escande's avatar William Escande
Browse files

Errorprone: JavaUtilDate

Date has a bad API that leads to bugs;
prefer java.time.Instant or LocalDate.

Since it is sometimes complicated to change this, this CL aim to enforce
the Errorprone for futur usage, but let the current one and only
suppress the error for existing issues.
Usage of these method should not be extended

Test: m Bluetooth
Bug: 365629730 # to track removal of exception
Bug: 344658662
Flag: Exempt, enforce error in the futur
Change-Id: I150d1a5ac63dfb756fa5711afc8dd9311ecfb279
parent 45919a32
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -341,6 +341,7 @@ android_app {
            "-Xep:InlineMeInliner:ERROR",
            "-Xep:InvalidBlockTag:ERROR",
            "-Xep:InvalidParam:ERROR",
            "-Xep:JavaUtilDate:ERROR",
            "-Xep:LoopOverCharArray:ERROR",
            "-Xep:MissingCasesInEnumSwitch:ERROR",
            "-Xep:MixedMutabilityReturnType:ERROR",
@@ -359,6 +360,7 @@ android_app {
            "-Xep:StringCharset:ERROR",
            "-Xep:SynchronizeOnNonFinalField:ERROR",
            "-Xep:ToStringReturnsNull:ERROR",
            "-Xep:UndefinedEquals:ERROR",
            "-Xep:UnnecessaryStringBuilder:ERROR",
            "-Xep:UnrecognisedJavadocTag:ERROR",
            "-Xep:UnusedMethod:ERROR",
+1 −0
Original line number Diff line number Diff line
@@ -114,6 +114,7 @@ public class BipDateTime {
    }

    @Override
    @SuppressWarnings("UndefinedEquals") // Related to java Date API that should be clean repo wide
    public boolean equals(Object o) {
        if (o == this) {
            return true;
+1 −0
Original line number Diff line number Diff line
@@ -938,6 +938,7 @@ public class AppScanStats {
        }
    }

    @SuppressWarnings("JavaUtilDate") // TODO: b/365629730 -- prefer Instant or LocalDate
    public synchronized void dumpToString(StringBuilder sb) {
        long currentTime = System.currentTimeMillis();
        long currTime = SystemClock.elapsedRealtime();
+12 −0
Original line number Diff line number Diff line
@@ -1224,6 +1224,7 @@ public class BluetoothMapAppParams {
        return mFilterPeriodBegin;
    }

    @SuppressWarnings("JavaUtilDate") // TODO: b/365629730 -- prefer Instant or LocalDate
    public String getFilterPeriodBeginString() {
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd'T'HHmmss");
        Date date = new Date(mFilterPeriodBegin);
@@ -1234,6 +1235,7 @@ public class BluetoothMapAppParams {
        this.mFilterPeriodBegin = filterPeriodBegin;
    }

    @SuppressWarnings("JavaUtilDate") // TODO: b/365629730 -- prefer Instant or LocalDate
    public void setFilterPeriodBegin(String filterPeriodBegin) throws ParseException {
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd'T'HHmmss");
        Date date = format.parse(filterPeriodBegin);
@@ -1244,6 +1246,7 @@ public class BluetoothMapAppParams {
        return mFilterPeriodBegin;
    }

    @SuppressWarnings("JavaUtilDate") // TODO: b/365629730 -- prefer Instant or LocalDate
    public String getFilterLastActivityBeginString() {
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd'T'HHmmss");
        Date date = new Date(mFilterPeriodBegin);
@@ -1254,6 +1257,7 @@ public class BluetoothMapAppParams {
        this.mFilterPeriodBegin = filterPeriodBegin;
    }

    @SuppressWarnings("JavaUtilDate") // TODO: b/365629730 -- prefer Instant or LocalDate
    public void setFilterLastActivityBegin(String filterPeriodBegin) throws ParseException {
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd'T'HHmmss");
        Date date = format.parse(filterPeriodBegin);
@@ -1268,6 +1272,7 @@ public class BluetoothMapAppParams {
        return mFilterPeriodEnd;
    }

    @SuppressWarnings("JavaUtilDate") // TODO: b/365629730 -- prefer Instant or LocalDate
    public String getFilterLastActivityEndString() {
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd'T'HHmmss");
        Date date = new Date(mFilterPeriodEnd);
@@ -1278,12 +1283,14 @@ public class BluetoothMapAppParams {
        this.mFilterPeriodEnd = filterPeriodEnd; // er reuse the same
    }

    @SuppressWarnings("JavaUtilDate") // TODO: b/365629730 -- prefer Instant or LocalDate
    public void setFilterPeriodEnd(String filterPeriodEnd) throws ParseException {
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd'T'HHmmss");
        Date date = format.parse(filterPeriodEnd);
        this.mFilterPeriodEnd = date.getTime();
    }

    @SuppressWarnings("JavaUtilDate") // TODO: b/365629730 -- prefer Instant or LocalDate
    public String getFilterPeriodEndString() {
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd'T'HHmmss");
        Date date = new Date(mFilterPeriodEnd);
@@ -1294,6 +1301,7 @@ public class BluetoothMapAppParams {
        this.mFilterPeriodEnd = filterPeriodEnd;
    }

    @SuppressWarnings("JavaUtilDate") // TODO: b/365629730 -- prefer Instant or LocalDate
    public void setFilterLastActivityEnd(String filterPeriodEnd) throws ParseException {
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd'T'HHmmss");
        Date date = format.parse(filterPeriodEnd);
@@ -1498,6 +1506,7 @@ public class BluetoothMapAppParams {
        return this.mLastActivity;
    }

    @SuppressWarnings("JavaUtilDate") // TODO: b/365629730 -- prefer Instant or LocalDate
    public String getLastActivityString() {
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd'T'HHmmssZ");
        Date date = new Date(mLastActivity);
@@ -1508,6 +1517,7 @@ public class BluetoothMapAppParams {
        this.mLastActivity = last;
    }

    @SuppressWarnings("JavaUtilDate") // TODO: b/365629730 -- prefer Instant or LocalDate
    public void setLastActivity(String lastActivity) throws ParseException {
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd'T'HHmmssZ");
        Date date = format.parse(lastActivity);
@@ -1744,6 +1754,7 @@ public class BluetoothMapAppParams {
        return mMseTime;
    }

    @SuppressWarnings("JavaUtilDate") // TODO: b/365629730 -- prefer Instant or LocalDate
    public String getMseTimeString() {
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd'T'HHmmssZ");
        Date date = new Date(getMseTime());
@@ -1754,6 +1765,7 @@ public class BluetoothMapAppParams {
        this.mMseTime = mseTime;
    }

    @SuppressWarnings("JavaUtilDate") // TODO: b/365629730 -- prefer Instant or LocalDate
    public void setMseTime(String mseTime) throws ParseException {
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd'T'HHmmssZ");
        Date date = format.parse(mseTime);
+2 −0
Original line number Diff line number Diff line
@@ -155,6 +155,7 @@ public class BluetoothMapConvoContactElement
        this.mChatState = Integer.valueOf(chatState);
    }

    @SuppressWarnings("JavaUtilDate") // TODO: b/365629730 -- prefer Instant or LocalDate
    public String getLastActivityString() {
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd'T'HHmmss");
        Date date = new Date(mLastActivity);
@@ -165,6 +166,7 @@ public class BluetoothMapConvoContactElement
        this.mLastActivity = dateTime;
    }

    @SuppressWarnings("JavaUtilDate") // TODO: b/365629730 -- prefer Instant or LocalDate
    public void setLastActivity(String lastActivity) throws ParseException {
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd'T'HHmmss");
        Date date = format.parse(lastActivity);
Loading