Skip to content

Commit 6d8686d

Browse files
authored
Merge pull request #754 from AppDevNext/UnixTimeRelativ2NowAxisValueFormatter
UnixTime relative to now AxisValueFormatter
2 parents f5c0c17 + 47c89dd commit 6d8686d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package info.appdev.chartexample.formatter
2+
3+
import info.appdev.charting.components.AxisBase
4+
import info.appdev.charting.formatter.IAxisValueFormatter
5+
import java.text.SimpleDateFormat
6+
import java.util.Locale
7+
8+
class UnixTimeRelative2NowAxisValueFormatter(val format: String = "yyyy-MM-dd'T'HH:mm:ss'Z'") : IAxisValueFormatter {
9+
10+
val simpleDateFormat = SimpleDateFormat(format, Locale.getDefault())
11+
12+
override fun getFormattedValue(value: Float, axis: AxisBase?): String {
13+
val relative2Now = System.currentTimeMillis() + (value.toLong() * 1000)
14+
return simpleDateFormat.format(relative2Now)
15+
}
16+
17+
}

0 commit comments

Comments
 (0)