我试图解析这个日期def working_days_in_range(from_date, to_date):
from_weekday = from_date.weekday()
to_weekday = to_date.weekday()
# If start date is after Friday, modify it to Monday
if from_weekday > 4:
from_weekday = 0
day_diff = to_weekday - from_weekday
whole_weeks = ((to_date - from_date).days - day_diff) / 7
workdays_in_whole_weeks = whole_weeks * 5
beginning_end_correction = min(day_diff, 5) - (max(to_weekday - 4, 0) % 5)
working_days = workdays_in_whole_weeks + beginning_end_correction
# Final sanity check (i.e. if the entire range is weekends)
return max(0, working_days)
,但我得到了一个Parse异常。
Mon Sep 21 2015 14:30:47 GMT+0000 (UTC)
我试过了:
W/System.err﹕ java.text.ParseException: Unparseable date: "Mon Sep 21 2015 14:30:47 GMT+0000 (UTC)" (at offset 0)
W/System.err﹕ at java.text.DateFormat.parse(DateFormat.java:626)
但是没有用,所以问题是:我必须使用什么格式来解析该日期?