android日期格式时间戳输出为"/日期(1393346946000+;0200)/
我想按以下格式转换当前时间: “/日期(139334694600+0200)/ 我该怎么做android日期格式时间戳输出为"/日期(1393346946000+;0200)/,android,date,timestamp,Android,Date,Timestamp,我想按以下格式转换当前时间: “/日期(139334694600+0200)/ 我该怎么做 public static Date getCurrentTime() { Calendar c = Calendar.getInstance(); System.out.println("Current time => " + c.getTimeInMillis()); long time = (System.currentTimeMillis()
public static Date getCurrentTime() {
Calendar c = Calendar.getInstance();
System.out.println("Current time => " + c.getTimeInMillis());
long time = (System.currentTimeMillis());
System.out.println("Current time2 => " + time);
Date currentTime = c.getTime();
return
currentTime;
}
使用此选项可将当前时间设置为所需格式
String inputPattern = "yyyy-MM-dd hh:mm:ss";
String outputPattern = "dd/MM";//here you can give your output format that's all
SimpleDateFormat inFormat = new SimpleDateFormat(inputPattern);
SimpleDateFormat outputFormat = new SimpleDateFormat(outputPattern);
Date date1 = null;
if (date != null) {
try {
date1 = inFormat.parse(date);
str = outputFormat.format(date1);
Log.d(null, str);
} catch (ParseException e) {
e.printStackTrace();
}
} else {
str = " ";
}