2014-09-19 18 views

回答

0

使用'S'獲得毫秒

public static String getCurrentTimeStamp() { 
    SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss S");//dd/MM/yyyy 
    Date now = new Date(); 
    String strDate = sdfDate.format(now); 
    return strDate; 
} 
0

使用此代碼我希望這將是對您有所幫助

String strDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(Calendar.getInstance().getTime()); 
0
public static String getCurrentTimeStamp() { 
    SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); 
    Date now = new Date(); 
    String strDate = sdfDate.format(now); 
    return strDate; 
} 
0

試試這個:

public static String getCurrentTimeStamp() { 
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); 
    Date now = new Date(); 
    String strDate = sdfDate.format(now); 
    return strDate; 
} 
0

試試這個代碼

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); 
相關問題