2013-11-28 17 views
2

블랙 베리 + 자바에서 밀리 초를 계산하는 방법을 알려 주실 수 있습니까?블랙 베리 + 자바에서 밀리 초를 계산하는 방법

static public String getTimeStamp(){ 

     String timeFormat = "HH.mm.ss"; 



     Date now = new Date(); 
     SimpleDateFormat sdf = new SimpleDateFormat(timeFormat); 
     return sdf.format(now); 
    } 
+0

사실 나는 코어 Java를 사용하는 블랙 베리에서 일하고있다 –

+0

왜 System.currentTimeMillis()를 사용하지 않습니까? –

답변

0

코드를 다음으로 변경하십시오 :

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에 의해 모듈로 당신에게 밀리 초를 제공하기 때문에.