[
https://issues.apache.org/jira/browse/NET-191?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12574050#action_12574050
]
jschneider edited comment on NET-191 at 2/29/08 6:25 PM:
-------------------------------------------------------------
I ran into the same issue today. It was a major issue for my organization.
I've modified FTPTimestampParserImpl with a workaround that does fix the issue.
I invite the community to scrutinize and improve the fix.
The code changes are shown below. I'll attach a source file as well.
{code}
public Calendar parseTimestamp(String timestampStr) throws ParseException {
Calendar now = Calendar.getInstance();
now.setTimeZone(this.getServerTimeZone());
Calendar working = Calendar.getInstance();
working.setTimeZone(this.getServerTimeZone());
ParsePosition pp = new ParsePosition(0);
Date parsed = null;
if (this.recentDateFormat != null) {
parsed = recentDateFormat.parse(timestampStr, pp);
// Start change
if (parsed == null
&& new GregorianCalendar().isLeapYear(now
.get(Calendar.YEAR))) {
SimpleDateFormat dateFormat = new
SimpleDateFormat("yyyy "
+ DEFAULT_RECENT_SDF);
pp = new ParsePosition(0);
timestampStr = now.get(Calendar.YEAR) + " " +
timestampStr;
parsed = dateFormat.parse(timestampStr, pp);
}
// End change
}
{code}
was (Author: jschneider):
I ran into the same issue today. It was a major issue for my organization.
I've modified FTPTimestampParserImpl with a workaround that does fix the
issue. It may not be the best, most bulletproof code as I was under a good
amount of pressure to just put a band-aid on production operations. I invite
the community to scrutinize and improve the fix.
The code changes are shown below. I'll attach a source file as well.
{code}
public Calendar parseTimestamp(String timestampStr) throws ParseException {
Calendar now = Calendar.getInstance();
now.setTimeZone(this.getServerTimeZone());
Calendar working = Calendar.getInstance();
working.setTimeZone(this.getServerTimeZone());
ParsePosition pp = new ParsePosition(0);
Date parsed = null;
if (this.recentDateFormat != null) {
parsed = recentDateFormat.parse(timestampStr, pp);
// Start change
if (parsed == null
&& new GregorianCalendar().isLeapYear(now
.get(Calendar.YEAR))) {
SimpleDateFormat dateFormat = new
SimpleDateFormat("yyyy "
+ DEFAULT_RECENT_SDF);
pp = new ParsePosition(0);
timestampStr = now.get(Calendar.YEAR) + " " +
timestampStr;
parsed = dateFormat.parse(timestampStr, pp);
}
// End change
}
{code}
> date parsing in the FTP client doesn't work for 29th Feb (leap years)
> ---------------------------------------------------------------------
>
> Key: NET-191
> URL: https://issues.apache.org/jira/browse/NET-191
> Project: Commons Net
> Issue Type: Bug
> Affects Versions: 1.4
> Environment: solaris/windows 1.4.1 commons-client, java 5
> Reporter: Anjan Bacchu
> Priority: Minor
> Attachments: FTPTimestampParserImpl.java
>
> Original Estimate: 24h
> Remaining Estimate: 24h
>
> http://blogs.lodgon.com/johan/Leap_year_issues_in_apache_commonsnet
> We have a production app that is being impacted as well. we have the same
> issue as the user here : not able to parse LEAP YEAR(29th feb) dates in Ftp
> client.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.