你可以試試下面的方法相同,
public static String getDate(long currentTimeMillis)
{
Date today = new Date(currentTimeMillis);
DateField date = new DateField("", DateField.DATE_TIME, TimeZone.getTimeZone("GMT+5:30"));
date.setDate(today);
Calendar cal = Calendar.getInstance();
cal.setTime(today);
String dateStr = "" + getTwoDigitStr(cal.get(Calendar.DATE)) + "-" + getTwoDigitStr(cal.get(Calendar.MONTH)+1) + "-" + cal.get(Calendar.YEAR);
return dateStr;
}
public static String getTime (long currentTimeMillis)
{
Date today = new Date(currentTimeMillis);
DateField date = new DateField ("", DateField.TIME, TimeZone.getTimeZone("GMT +5:30") );
date.setDate(today);
Calendar cal = Calendar.getInstance();
cal.setTime(today);
String timeStr = "" + cal.get(Calendar.HOUR) + ":" + cal.get(Calendar.MINUTE);
return timeStr;
}
感謝的人它的工作好...我怎麼能變成最新最快的格式? – selladurai 2012-02-20 12:04:12
它非常簡單的過程,首先嚐試你自己。否則我會在稍後告訴你。 – Android 2012-02-20 12:06:03
它應該在24小時內返回您的時間,在這裏它工作正常,只需檢查您的手機設置。 – Android 2012-02-20 12:12:45