Changeset 4596 for trunk/gli


Ignore:
Timestamp:
2003-06-12T12:38:05+12:00 (21 years ago)
Author:
jmt12
Message:

2030125: Several string lengths were hardcoded which caused an attempt to parse a long from '979012594730s'. Now the lengths are calculated.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/gui/OptionsPane.java

    r4367 r4596  
    659659        return d.toString();
    660660    }
    661     /** extracts the date from the file name */
     661    /** extracts the date from the file name, which is of the form 'build_log.'<long>[scu]'.txt' */
    662662    private Date getDateFromFileName() {
    663663        String name = this.file.getName();
    664         String date_string = name.substring(10, 23);//name.length()-4);
    665         return new Date(Long.parseLong(date_string));
     664        // Need to exclude first '.'
     665        int first_index = name.indexOf(".") + 1;
     666        // Need to exclude state letter before last '.'
     667        int last_index = name.lastIndexOf(".") - 1;
     668        if(first_index > 0 && last_index > 0 && first_index < last_index) {
     669        String date_string = name.substring(first_index, last_index);
     670        return new Date(Long.parseLong(date_string));
     671        }
     672        else {
     673        return new Date(); // Current date
     674        }
    666675    }
    667676
Note: See TracChangeset for help on using the changeset viewer.