我有這樣的方法:如何將日期日期轉換爲java中的西式日期?
//datetime is millisecond
public static String getStringDateFormatMonth(long datetime) {
String yearlessPattern = "yyyy年MM月";
SimpleDateFormat yearlessSDF = new SimpleDateFormat(yearlessPattern);
Date date = new Date(datetime);
String datestr = yearlessSDF.format(date);
return datestr;
}
public static String getStringDateFormat(long datetime) {
String yearlessPattern = "dd日";
SimpleDateFormat yearlessSDF = new SimpleDateFormat(yearlessPattern);
SimpleDateFormat sdfDay = new SimpleDateFormat("E", Locale.JAPAN);
Date date = new Date(datetime);
String datestr = yearlessSDF.format(date) + "(" + sdfDay.format(date) + ")";
return datestr;
}
Intialize字符串:
String a = LifelogUtil.getStringDateFormatMonth(currentDate.getTimeInMillis())
+ LifelogUtil.getStringDateFormat(currentDate.getTimeInMillis());
,結果我得到的是
2015年07月19日(日)
現在我想對這個日期轉換回西方日期作爲這種格式「yyyy-MM-dd」,但我無法想象如何做到這一點。請幫幫我!謝謝!
非常好,謝謝;) – Kakashi