我在我的实时图表中将时间/日期设置为x值,但时间与我的安卓时间不匹配,有人可以检查我的代码
final DateFormat sdf = android.text.format.DateFormat.getTimeFormat(this);
graph.getGridLabelRenderer().setLabelFormatter(new DefaultLabelFormatter() {
@Override
public String formatLabel(double value, boolean isValueX) {
if (isValueX) {
long Valuemilis = (new Double(value)).longValue();
return sdf.format(Valuemilis*1000);
}
else {
return null;
}
}
});
答案 0 :(得分:0)
要以毫秒为单位获得系统时间,可以使用Date.java
类。
下面的代码片段可以解决您的问题。
long Valuemilis = new Date().getTime();