我有毫秒。 我需要它转换为日期格式
I have milliseconds. I need it to be converted to date format of
例如:
23/10/2011
23/10/2011
如何实现的呢?
任何帮助,真是AP preciated。
any help is really appreciated.
只是试试这个样品code: -
Just Try this Sample code:-
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
public class Test {
/**
* Main Method
*/
public static void main(String[] args) {
System.out.println(getDate(82233213123L, "dd/MM/yyyy hh:mm:ss.SSS"));
}
/**
* Return date in specified format.
* @param milliSeconds Date in milliseconds
* @param dateFormat Date format
* @return String representing date in specified format
*/
public static String getDate(long milliSeconds, String dateFormat)
{
// Create a DateFormatter object for displaying date in specified format.
SimpleDateFormat formatter = new SimpleDateFormat(dateFormat);
// Create a calendar object that will convert the date and time value in milliseconds to date.
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(milliSeconds);
return formatter.format(calendar.getTime());
}
}
我希望这帮助...
I hope this help...
上一篇:使用HTTP多部分表单数据的Android上传视频到远程服务器表单、上传、部分、服务器
下一篇:失败[INSTALL_FAILED_OLDER_SDK]安卓-LINSTALL_FAILED_OLDER_SDK