我想按用户解析给定日期,但使用特定格式:星期的星期几。如何仅使用SimpleDateFormat解析日期
到目前为止,这是我做的:
SimpleDateFormat format = new SimpleDateFormat("E", Locale.ENGLISH);
try {
Date date = format.parse ("Friday");
Calendar calendar = format.getCalendar();
calendar.add(Calendar.WEEK_OF_YEAR, 1);
return calendar.getTime();
}
catch (ParseException pe) {
return null;
}
但这返回我:
2 janv. 1970 00:00:00
我想这回我未来星期五(在我们的延时,4 nov. 2011
)
我该怎么办?
如果OP要未来的日子,然后他可以检查当天对过去的一天,如果它通过本周,然后加1周。 –
@JigarJoshi:是的,这就是我的意思。我会澄清我的评论。 –
你可以发表一个关于你如何处理JodaTime的例子吗?我不明白我该怎么做。谢谢:) –