commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John Schneider (JIRA)" <j...@apache.org>
Subject [jira] Commented: (NET-191) date parsing in the FTP client doesn't work for 29th Feb (leap years)
Date Sat, 01 Mar 2008 02:03:51 GMT

    [ https://issues.apache.org/jira/browse/NET-191?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12574050#action_12574050
] 

John Schneider commented on NET-191:
------------------------------------

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.


Mime
View raw message