Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在blackberry+;JAVA_Java_Blackberry - Fatal编程技术网

如何在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);

你能告诉我如何用blackberry+java计算毫秒吗?我得到的时间戳是这样的

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);
}