如何在blackberry+;JAVA
你能告诉我如何用blackberry+java计算毫秒吗?我得到的时间戳是这样的如何在blackberry+;JAVA,java,blackberry,Java,Blackberry,你能告诉我如何用blackberry+java计算毫秒吗?我得到的时间戳是这样的 static public String getTimeStamp(){ String timeFormat = "HH.mm.ss"; Date now = new Date(); SimpleDateFormat sdf = new SimpleDateFormat(timeFormat); return sdf.format(now);
static public String getTimeStamp(){
String timeFormat = "HH.mm.ss";
Date now = new Date();
SimpleDateFormat sdf = new SimpleDateFormat(timeFormat);
return sdf.format(now);
}
尝试:
请参阅:
HttpDateParser在BB中是一个功能强大的util类。当谈到日期时,我总是在BB时间使用它将代码更改为:
static public String getTimeStamp(){
String timeFormat = "HH.mm.ss.SSS ";
Date now = new Date();
SimpleDateFormat sdf = new SimpleDateFormat(timeFormat);
return sdf.format(now).substring(timeFormat.length() - 4);
}
在几秒钟内就搞砸了
另一种更优雅的方法是:
static public String getTimeStamp(){
return "" + System.currentTimeMillis()%1000);
}
因为模乘1000得到的是毫秒。实际上我在黑莓手机上工作,黑莓手机使用的是Java内核,为什么不使用System.currentTimeMillis()?
static public String getTimeStamp(){
return "" + System.currentTimeMillis()%1000);
}