instantToLocal

fun instantToLocal(time: Instant, zoneOffset: ZoneOffset = ZoneOffset.systemDefault().rules.getOffset(time)): LocalDateTime

Converts Instant time to LocalDateTime

For example, each DataPoint of a reading BloodGlucose result has the data's measurement time with timestamp The timestamp is Instant time. It can be converted to LocalDateTime like:

val readRequest = DataTypes.BLOOD_GLUCOSE.readDataRequestBuilder
    .setInstantTimeFilter(instantTimeFilter)
    .build()

val result: List<HealthDataPoint> = healthDataStore.readData(readRequest).dataList

result.forEach { bloodGlucoseDataPoint ->
    val seriesData = bloodGlucoseDataPoint.getValue(DataType.BloodGlucoseType.SERIES_DATA)
    seriesData.forEach { bloodGlucose ->
         val timestamp = bloodGlucose.timestamp
         // Converting Instant of 'timestamp' to LocalDateTime by using DataUtilHelper.instantToLocal
         val localTime = DataUtilHelper.instantToLocal(timestamp, bloodGlucoseDataPoint.zoneOffset)
    }
}

Return

LocalDateTime object for given time and zoneId

Parameters

time

A Instant time to convert to LocalDateTime

zoneOffset

A zone offset. If it is not set, the system's default time-zone is set.

Preferences Submitted

You have successfully updated your cookie preferences.