2012-01-25 190 views

回答

2

有點哈克因爲Asia/Calcultta

編輯:還發現this

public class Foo { 
    public static void main(String[] args) throws Exception { 
     String date = "Wed Jan 18 08:50:04 Asia/Calcutta 2012"; 
     System.out.println(formatDate(date)); 
    } 

    private static String formatDate(String date) throws Exception { 
     String year = date.substring(date.lastIndexOf(' ') + 1); 
     DateFormat sdf = new SimpleDateFormat("EEE MMM dd kk:mm:ss"); 
     SimpleDateFormat fmt = new SimpleDateFormat(String.format("dd.MM.%s", 
                    year)); 
     Date parse = sdf.parse(date); 
     return fmt.format(parse); 
    } 
} 
0

嘗試在你的代碼:

SimpleDateFormat sdfDate = new SimpleDateFormat("dd.MM.yyyy"); 
      java.util.Date date = new java.util.Date(); 
      String strDate = sdfDate.format(date); 

我試過了。