Formats past time by comparing with the current time.
- Add the following in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
- Add the dependency
dependencies {
implementation 'com.github.lusajo143:TimeFormatter:1.0.3'
}
try {
Date date = new Date();
TimeFormatter formatter = new TimeFormatter(date.getTime());
String time = formatter.format();
// Use time as you wish
Toast.makeText(this, time, Toast.LENGTH_SHORT).show();
} catch (JSONException e) {
e.printStackTrace();
}
Fill free to contribute 😁