mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-28 21:06:50 +01:00
parent
a5dd88df53
commit
67a1191a3c
@ -131,7 +131,7 @@ public class GPXExporter implements ActivityTrackExporter {
|
|||||||
ser.attribute(NS_DEFAULT, "lon", formatLocation(location.getLongitude()));
|
ser.attribute(NS_DEFAULT, "lon", formatLocation(location.getLongitude()));
|
||||||
ser.attribute(NS_DEFAULT, "lat", formatLocation(location.getLatitude()));
|
ser.attribute(NS_DEFAULT, "lat", formatLocation(location.getLatitude()));
|
||||||
ser.startTag(NS_DEFAULT, "ele").text(formatLocation(location.getAltitude())).endTag(NS_DEFAULT, "ele");
|
ser.startTag(NS_DEFAULT, "ele").text(formatLocation(location.getAltitude())).endTag(NS_DEFAULT, "ele");
|
||||||
ser.startTag(NS_DEFAULT, "time").text(formatTime(point.getTime())).endTag(NS_DEFAULT, "time");
|
ser.startTag(NS_DEFAULT, "time").text(DateTimeUtils.formatIso8601UTC(point.getTime())).endTag(NS_DEFAULT, "time");
|
||||||
String description = point.getDescription();
|
String description = point.getDescription();
|
||||||
if (description != null) {
|
if (description != null) {
|
||||||
ser.startTag(NS_DEFAULT, "desc").text(description).endTag(NS_DEFAULT, "desc");
|
ser.startTag(NS_DEFAULT, "desc").text(description).endTag(NS_DEFAULT, "desc");
|
||||||
|
@ -51,7 +51,12 @@ public class DateTimeUtils {
|
|||||||
@Override
|
@Override
|
||||||
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition pos) {
|
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition pos) {
|
||||||
StringBuffer rfcFormat = super.format(date, toAppendTo, pos);
|
StringBuffer rfcFormat = super.format(date, toAppendTo, pos);
|
||||||
return rfcFormat.insert(rfcFormat.length() - 2, ":");
|
if (this.getTimeZone().equals(TimeZone.getTimeZone("UTC"))) {
|
||||||
|
rfcFormat.setLength(rfcFormat.length()-5);
|
||||||
|
return rfcFormat.append("Z");
|
||||||
|
} else {
|
||||||
|
return rfcFormat.insert(rfcFormat.length() - 2, ":");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}; //no public access, we have to workaround Android bugs
|
}; //no public access, we have to workaround Android bugs
|
||||||
@ -64,6 +69,17 @@ public class DateTimeUtils {
|
|||||||
if(GBApplication.isRunningNougatOrLater()){
|
if(GBApplication.isRunningNougatOrLater()){
|
||||||
return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX", Locale.US).format(date);
|
return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX", Locale.US).format(date);
|
||||||
}
|
}
|
||||||
|
ISO_8601_FORMAT.setTimeZone(TimeZone.getDefault());
|
||||||
|
return ISO_8601_FORMAT.format(date);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String formatIso8601UTC(Date date) {
|
||||||
|
if(GBApplication.isRunningNougatOrLater()){
|
||||||
|
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX", Locale.US);
|
||||||
|
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
|
return sdf.format(date);
|
||||||
|
}
|
||||||
|
ISO_8601_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
return ISO_8601_FORMAT.format(date);
|
return ISO_8601_FORMAT.format(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user