SeadasFileReader { static ProductData.UTC parseUtcDate(String timeString) { try { if (timeString.matches("\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z")) { return ProductData.UTC.parse(timeString, "yyyy-MM-dd'T'HH:mm:ss'Z'"); } else if (timeString.matches("\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z")) { timeString = timeString.substring(0, timeString.length() - 1); return ProductData.UTC.parse(timeString, "yyyy-MM-dd'T'HH:mm:ss"); } else if (timeString.matches("\\d{4}\\d{2}\\d{2}T\\d{6}Z")) { return ProductData.UTC.parse(timeString, "yyyyMMdd'T'HHmmss'Z'"); } else if (timeString.matches("\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\.\\d{6}")) { return ProductData.UTC.parse(timeString, "yyyy-MM-dd HH:mm:ss"); } else if (timeString.matches("\\d{4}\\d{2}\\d{2} \\d{2}:\\d{2}:\\d{2}\\.\\d{6}")) { return ProductData.UTC.parse(timeString, "yyyyMMdd HH:mm:ss"); } else if (timeString.matches("\\d{4}\\d{3}\\d{2}\\d{2}\\d{2}\\d{3}")) { Date date = ProductData.UTC.createDateFormat("yyyyDDDHHmmssSSS").parse(timeString); String milliSeconds = timeString.substring(timeString.length() - 3); return ProductData.UTC.create(date, Long.parseLong(milliSeconds) * 1000); } } catch (ParseException ignored) { } return null; } SeadasFileReader(SeadasProductReader productReader); abstract Product createProduct(); synchronized void readBandData(Band destBand, int sourceOffsetX, int sourceOffsetY, int sourceWidth,
            int sourceHeight, int sourceStepX, int sourceStepY, ProductData destBuffer,
            ProgressMonitor pm); FlagCoding readFlagCoding(Product product, Band bandName); Map<Band, Variable> addBands(Product product,
            List<Variable> variables); void addGlobalMetadata(Product product); void addInputParamMetadata(Product product); void addScientificMetadata(Product product); void addBandMetadata(Product product); void computeLatLonBandData(int height, int width, Band latBand, Band lonBand,
            final float[] latRawData, final float[] lonRawData,
            final int[] colPoints); float computeGeoPixel(final float a, final float b, final double weight); boolean getDefaultFlip(); static void reverse(float[] data); Attribute findAttribute(String name, List<Attribute> attributesList); Attribute findAttribute(String name); String getStringAttribute(String key, List<Attribute> attributeList); String getStringAttribute(String key); int getIntAttribute(String key, List<Attribute> globalAttributes); int getUShortAttribute(Attribute attribute); int getIntAttribute(String key); float getFloatAttribute(String key, List<Attribute> globalAttributes); float getFloatAttribute(String key); ProductData.UTC getUTCAttribute(String key); static int getProductDataType(Variable variable); static int getProductDataType(DataType dataType, boolean unsigned, boolean rasterDataOnly); int convertToFlagMask(String name); ProductData readData(Variable variable);  }
@Test public void testParseUtcDate() throws Exception { DateFormat format = ProductData.UTC.createDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); assertNull(SeadasFileReader.parseUtcDate("foo")); ProductData.UTC parsed = SeadasFileReader.parseUtcDate("2012-03-05T12:13:14Z"); assertNotNull(parsed); assertEquals("2012-03-05T12:13:14.000Z", format.format(parsed.getAsDate())); assertEquals(0, parsed.getMicroSecondsFraction()); parsed = SeadasFileReader.parseUtcDate("2012-03-05T12:13:14.123Z"); assertNotNull(parsed); assertEquals("2012-03-05T12:13:14.123Z", format.format(parsed.getAsDate())); assertEquals(123000, parsed.getMicroSecondsFraction()); parsed = SeadasFileReader.parseUtcDate("20120305T121314Z"); assertNotNull(parsed); assertEquals("2012-03-05T12:13:14.000Z", format.format(parsed.getAsDate())); assertEquals(0, parsed.getMicroSecondsFraction()); parsed = SeadasFileReader.parseUtcDate("2012-03-05 12:13:14.123456"); assertNotNull(parsed); assertEquals("2012-03-05T12:13:14.123Z", format.format(parsed.getAsDate())); assertEquals(123456, parsed.getMicroSecondsFraction()); parsed = SeadasFileReader.parseUtcDate("20120305 12:13:14.123456"); assertNotNull(parsed); assertEquals("2012-03-05T12:13:14.123Z", format.format(parsed.getAsDate())); assertEquals(123456, parsed.getMicroSecondsFraction()); parsed = SeadasFileReader.parseUtcDate("2012065121314123"); assertNotNull(parsed); assertEquals("2012-03-05T12:13:14.123Z", format.format(parsed.getAsDate())); assertEquals(123000, parsed.getMicroSecondsFraction()); }