开发者

how to format date in blackberry

I am retrieving a string in the form of "2010-10-20" from a xml database,and every time this string keeps on changing.I need to format this string to something like October 20 2010.I tried using SimpleDateFormat and then calling the format method on it and 开发者_运维百科passing the string as the argument.But the execution stops when it encounters this line.Can anyone please help me out?


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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜