-1
我從xml數據庫中檢索「2010-10-20」形式的字符串,並且每次該字符串不斷變化。我需要將此字符串格式化爲類似於10月20日我嘗試使用SimpleDateFormat,然後調用它的格式方法,並將字符串作爲參數傳遞。但是遇到此行時執行停止。可以請任何人幫助我嗎?如何在黑莓中格式化日期
我從xml數據庫中檢索「2010-10-20」形式的字符串,並且每次該字符串不斷變化。我需要將此字符串格式化爲類似於10月20日我嘗試使用SimpleDateFormat,然後調用它的格式方法,並將字符串作爲參數傳遞。但是遇到此行時執行停止。可以請任何人幫助我嗎?如何在黑莓中格式化日期
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mma");
Date timenow = new Date(System.currentTimeMillis());
Calendar cal = Calendar.getInstance();
cal.setTimeZone(TimeZone.getTimeZone("Europe/Istanbul"));
cal.setTime(timenow);
String formatedTime = sdf.format(cal);
or
StringBuffer sb = new StringBuffer();
DateFormat.getInstance(DateFormat.DATETIME_DEFAULT).formatLocal(sb,System.currentTimeMillis());
String localFormatedDate = sb.toString();
你可以發佈代碼嗎? – 2011-01-11 09:53:21