- Date change for RL History

This commit is contained in:
Andy Rozman 2020-04-22 12:52:25 +01:00
parent 88554ee376
commit 4d408f55b9
4 changed files with 55 additions and 2 deletions

View file

@ -23,6 +23,7 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistor
import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil; import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil;
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry; import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry;
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState; import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
import info.nightscout.androidaps.utils.DateUtil;
/** /**
* Created by andy on 5/19/18. * Created by andy on 5/19/18.
@ -131,7 +132,7 @@ public class RileyLinkStatusHistory extends Fragment implements RefreshableInter
RLHistoryItem item = historyList.get(position); RLHistoryItem item = historyList.get(position);
if (item != null) { if (item != null) {
holder.timeView.setText(StringUtil.toDateTimeString(item.getDateTime())); holder.timeView.setText(DateUtil.dateAndTimeAndSecondsString(item.getDateTime().toDateTime().getMillis()));
holder.typeView.setText(item.getSource().getDesc()); holder.typeView.setText(item.getSource().getDesc());
holder.valueView.setText(item.getDescription()); holder.valueView.setText(item.getDescription());
} }

View file

@ -7,6 +7,8 @@ import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.utils.DateUtil;
/** /**
* Created by geoff on 4/28/15. * Created by geoff on 4/28/15.
* modified by Andy * modified by Andy
@ -83,7 +85,8 @@ public class StringUtil {
public static String toDateTimeString(LocalDateTime localDateTime) { public static String toDateTimeString(LocalDateTime localDateTime) {
return localDateTime.toString("dd.MM.yyyy HH:mm:ss"); return DateUtil.dateAndTimeAndSecondsString(localDateTime.toDateTime().getMillis());
//return localDateTime.toString("dd.MM.yyyy HH:mm:ss");
} }

View file

@ -19,6 +19,7 @@ import java.util.Calendar;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Set; import java.util.Set;
import info.nightscout.androidaps.BuildConfig; import info.nightscout.androidaps.BuildConfig;

View file

@ -1,6 +1,9 @@
package info.nightscout.androidaps.utils; package info.nightscout.androidaps.utils;
import org.joda.time.LocalDateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -8,7 +11,9 @@ import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import java.text.DateFormat;
import java.util.Date; import java.util.Date;
import java.util.Locale;
import info.AAPSMocker; import info.AAPSMocker;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
@ -89,6 +94,49 @@ public class DateUtilTest {
Assert.assertEquals("(1h 1')", DateUtil.timeFrameString((T.hours(1).msecs() + T.mins(1).msecs()))); Assert.assertEquals("(1h 1')", DateUtil.timeFrameString((T.hours(1).msecs() + T.mins(1).msecs())));
} }
@Test
public void dateTimeFormat() {
int style = DateFormat.SHORT;
//Also try with style = DateFormat.FULL and DateFormat.SHORT
Date date = new Date();
DateFormat df;
df = DateFormat.getDateInstance(style, Locale.UK);
System.out.println("United Kingdom: " + df.format(date));
df = DateFormat.getDateInstance(style, Locale.US);
System.out.println("USA: " + df.format(date));
df = DateFormat.getDateInstance(style, Locale.FRANCE);
System.out.println("France: " + df.format(date));
df = DateFormat.getDateInstance(style, Locale.ITALY);
System.out.println("Italy: " + df.format(date));
df = DateFormat.getDateInstance(style, Locale.JAPAN);
System.out.println("Japan: " + df.format(date));
df = DateFormat.getDateInstance(style, Locale.UK);
System.out.println("United Kingdom: " + df.format(date));
int styles[] = { DateFormat.DEFAULT, DateFormat.FULL, DateFormat.LONG, DateFormat.MEDIUM, DateFormat.SHORT};
for (int styleX : styles) {
df = DateFormat.getDateInstance(styleX, new Locale("en"));
System.out.println("English: style=" + styleX + ", result=" + df.format(date));
}
DateTimeFormatter dateTimeFormat = DateTimeFormat.shortDate();
LocalDateTime lcd = new LocalDateTime();
System.out.println("English: LocalDateTime=" + dateTimeFormat.print(lcd));
// public static final int DEFAULT = 2;
// public static final int FULL = 0;
// public static final int LONG = 1;
// public static final int MEDIUM = 2;
// public static final int SHORT = 3;
}
@Before @Before
public void prepareMock() { public void prepareMock() {
AAPSMocker.mockMainApp(); AAPSMocker.mockMainApp();