class ClimFileFactory implements TemporalFileFactory {

    public TemporalFile createTemporalFile(final File file) {
        final String filename = file.getName();
        if (filename.length() < 21) {
            return null;
        }
        if (!filename.startsWith(FILENAME_PREFIX)) {
            return null;
        }
        if (!filename.endsWith(FILENAME_SUFFIX)) {
            return null;
        }
        int year1;
        int month1;
        int year2;
        int month2;
        try {
            year1 = Integer.parseInt(filename.substring(TIME1_OFFSET, TIME1_OFFSET + 4));
            month1 = Integer.parseInt(filename.substring(TIME1_OFFSET + 4, TIME1_OFFSET + 6));
            year2 = Integer.parseInt(filename.substring(TIME2_OFFSET, TIME2_OFFSET + 4));
            month2 = Integer.parseInt(filename.substring(TIME2_OFFSET + 4, TIME2_OFFSET + 6));
        } catch (NumberFormatException e) {
            return null;
        }
        final long startTime = computeTime(year1, month1);
        final long endTime = computeTime(year2, month2 + 1) - 1;
        return new TemporalFile(file, new Date(startTime), new Date(endTime));

    }

}