long time = System.currentTimeMillis(); Date now = new Date(time); SimpleDateFormat df = new SimpleDateFormat("yyMMddHHmmss"); String strId =df.format(now); System.out.println(strId);
to get Time using: (Calendar.getInstance()).get(int HMS); param HMS could be Calendar.HOUR_OF_DAY Calendar.MINUTE Calendar.SECOND method get(int ) return int-type value of the specified param
.Canlendar
System
Date now = new Date(time);
SimpleDateFormat df = new SimpleDateFormat("yyMMddHHmmss");
String strId =df.format(now);
System.out.println(strId);
param HMS could be Calendar.HOUR_OF_DAY
Calendar.MINUTE
Calendar.SECOND
method get(int ) return int-type value of the
specified param
private DateFormat formater;
private String currentdate;
private Date today;
private Locale loca;
loca=Locale.getDefault();
formater=DateFormat.getDateTimeInstance(DateFormat.FULL,DateFormat.MEDIUM,loca);
today=new Date();
currentdate=formater.format(today);
自我感觉这样好一点,java tutorial也是这样写的