2012-08-06 34 views

回答

0

我做到了通过使用设定功能

  String time = message.substring(7, 11); 
      Calendar c = Calendar.getInstance(); 
      c.set(Calendar.HOUR_OF_DAY,Integer.parseInt(message.substring(7, 9))); 
      c.set(Calendar.MINUTE,Integer.parseInt(message.substring(9, 11))); 

       SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm"); 
       String formattedDate = df.format(c.getTime()); 
0

这里来示例函数来格式化,只要你喜欢的日期,希望这有助于

public static String getFormattedDate() { 
     return getFormattedDate(System.currentTimeMillis()); 
    } 
    public static String getFormattedDate(long millis) { 
     if (StringUtils.isEmpty(millis+"") || millis<=0) return ""; 

     return getFormattedDate(new Date(millis)); 
    } 
    public static String getFormattedDate(Date date) { 

     try { 
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.US); 
      return sdf.format(date); 
     } 
     catch (Exception ex) { 
      return ""; 
     } 
    }