commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (NET-403) file.getTimestamp(); showing a difference of TIME ZONE RAWOFFSET
Date Tue, 26 Apr 2011 11:08:03 GMT

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

Sebb commented on NET-403:
--------------------------

The year difference for the US test is because the file date is a short date, and short dates
in the future are treated as being in the past unless you enable lenient future dates.

Try again with the following config:

{code}
FTPClientConfig config = new FTPClientConfig();
config.setLenientFutureDates(true);
ftp.configure(config);
{code}

As far as I can tell, the India=>India test is working correctly.

> file.getTimestamp(); showing a difference of TIME ZONE RAWOFFSET
> ----------------------------------------------------------------
>
>                 Key: NET-403
>                 URL: https://issues.apache.org/jira/browse/NET-403
>             Project: Commons Net
>          Issue Type: Bug
>          Components: FTP
>    Affects Versions: 2.0, 2.2
>         Environment: JDK 1.5, commons-net-2.2
>            Reporter: Jayakumar T
>
> After Connecting an FTP server in the Same Timezone, Date And Time, I created a File
and run the program shown below to get the created or modified time of that file.
> But, file.getTimestamp(); is showing a difference of TIME ZONE RAWOFFSET between local
time and File Creation time. Please see the logs below.
> {code}
> Calendar calendar = Calendar.getInstance();
> FTPFile[] payoutFiles = ftp.listFiles();
> 			
> 			
> if(payoutFiles!=null)
> {
>     for (FTPFile file : payoutFiles) {
>     Calendar fileTime=file.getTimestamp();
>     
>      log.info("FTP TIME ZONE: "+fileTime.getTimeZone().getDisplayName());
>      log.info("LOCAL TIME ZONE: "+calendar.getTimeZone().getDisplayName());
>      
>      log.info("FTP ZONE_OFFSET: " +fileTime.get(Calendar.ZONE_OFFSET));
>      log.info("LOCAL ZONE_OFFSET: " +calendar.get(Calendar.ZONE_OFFSET));
> 					
>      log.info("FTP TIME: " +fileTime.toString());
>      log.info("LOCAL TIME: " +calendar.toString());
> 					
>      log.info("FTP TIME: " +fileTime.getTimeInMillis());
>      log.info("LOCAL TIME: " +calendar.getTimeInMillis());
> 					
>      log.info("FTP HOUR: " +fileTime.get(Calendar.HOUR_OF_DAY));
>      log.info("LOCAL HOUR: " +calendar.get(Calendar.HOUR_OF_DAY));
> 					
>      log.info("FTP MINUTE: " +fileTime.get(Calendar.MINUTE));
>      log.info("LOCAL MINUTE: " +calendar.get(Calendar.MINUTE));
> }
> {code}
> GETTING OUTPUT
> {noformat}
> [INFO,CheckFTP,main] FTP TIME ZONE: India Standard Time
> [INFO,CheckFTP,main] LOCAL TIME ZONE: India Standard Time
> [INFO,CheckFTP,main] FTP ZONE_OFFSET: 19800000
> [INFO,CheckFTP,main] LOCAL ZONE_OFFSET: 19800000
> [INFO,CheckFTP,main] FTP TIME: java.util.GregorianCalendar[time=1302151140000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Asia/Calcutta",offset=19800000,dstSavings=0,useDaylight=false,transitions=6,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2011,MONTH=3,WEEK_OF_YEAR=15,WEEK_OF_MONTH=2,DAY_OF_MONTH=7,DAY_OF_YEAR=97,DAY_OF_WEEK=5,DAY_OF_WEEK_IN_MONTH=1,AM_PM=0,HOUR=10,HOUR_OF_DAY=10,MINUTE=9,SECOND=0,MILLISECOND=0,ZONE_OFFSET=19800000,DST_OFFSET=0]
> [INFO,CheckFTP,main] LOCAL TIME: java.util.GregorianCalendar[time=1302173106873,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Asia/Calcutta",offset=19800000,dstSavings=0,useDaylight=false,transitions=6,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2011,MONTH=3,WEEK_OF_YEAR=15,WEEK_OF_MONTH=2,DAY_OF_MONTH=7,DAY_OF_YEAR=97,DAY_OF_WEEK=5,DAY_OF_WEEK_IN_MONTH=1,AM_PM=1,HOUR=4,HOUR_OF_DAY=16,MINUTE=15,SECOND=6,MILLISECOND=873,ZONE_OFFSET=19800000,DST_OFFSET=0]
> [INFO,CheckFTP,main] FTP TIME: 1302151140000
> [INFO,CheckFTP,main] LOCAL TIME: 1302173106873
> [INFO,CheckFTP,main] FTP HOURS: 10
> [INFO,CheckFTP,main] LOCAL HOURS: 16
> [INFO,CheckFTP,main] FTP MINUTE: 9
> [INFO,CheckFTP,main] LOCAL MINUTE: 15
> {noformat}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message