I'm a volunteer trying to create an app for a local organization that assists people with recovery, employment, support, and training called REST please help me. I created this class to represent time as a prototype. What I need is how to represent an example such as: 1:45 PM - 2:35 PM, 8 AM - 8:30 AM, and so on. I need this solution to work on minimumSdk 21 as Duration requires api 26 and that will not do because the app will not be compatible with most device.
import java.time.LocalTime;
import java.time.Duration;
class JavaTime {
private String local;
public JavaTime() {
}
public static void main(String[] args) {
JavaTime java_time = new JavaTime();
java_time.local = LocalTime.MIN.plus(Duration.ofMinutes(260L)).toString();
System.out.println(java_time.local);
}
}
Output:4:20
Here is the method I need to finish in the database:
public void getMondayGroup(int id) {
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(DBUtil.MONDAY_TABLE,
new String[]{DBUtil.KEY_ID,
DBUtil.KEY_GROUP_NAME,
DBUtil.KEY_GROUP_DAY,
DBUtil.KEY_START_TIME,
DBUtil.KEY_END_TIME},
DBUtil.KEY_ID + "=?",
new String[]{String.valueOf(id)},null,null,null,null);
if (cursor != null) {
cursor.moveToFirst();
}
Groups groups = new Groups();
if(cursor != null) {
groups.setId(Integer.parseInt(cursor.getString(cursor.getColumnIndex(DBUtil.KEY_ID))));
groups.setGroupName(cursor.getString(cursor.getColumnIndex(DBUtil.KEY_GROUP_NAME)));
groups.setGroupDay(cursor.getString(cursor.getColumnIndex(DBUtil.KEY_GROUP_DAY)));
groups.setGroupStartTime(cursor.getString(cursor.getColumnIndex(DBUtil.KEY_START_TIME)));
groups.setGroupEndTime(cursor.getString(cursor.getColumnIndex(DBUtil.KEY_END_TIME)));
// Issue
String local = local_time.MIN.plus(Duration.ofMinutes(260L)).toString();
// I want to replace this date with time
DateFormat dateFormat = DateFormat.getDateInstance();
String formattedDate = dateFormat.format(new Date(cursor.getLong(
cursor.getColumnIndex(DBUtil.KEY_START_TIME)).getTime()); // Feb 23, 2020
groups.setDateCreated(formattedDate);*/
}
}