// ===================================================== // setEXIFpictureMetadaten() // // Aus dem Image-Original werden die EXIF-Daten f�r die // PM_PictureMetadatenX geholt und eingetragen // ===================================================== public static void setEXIFpictureMetadaten(PM_Picture picture) { PM_PictureImageMetadaten imageMetadaten = picture.getImageMetadaten(); // ---------------------------------------------------- // FujiFilm Makernote: SequenceNummer --> virtPicture // ---------------------------------------------------- // ------------------------------------------------------- // Date // ------------------------------------------------------ String tagDatum = "Date/Time Original"; String description = ""; if (imageMetadaten.hasTag(tagDatum)) { description = imageMetadaten.getDescription(tagDatum); } // ---------------------------------------------------- // Datum nicht vorhanden oder ung�ltig // ---------------------------------------------------- Date myDate = null; if (description.length() == 0 || description.equals("0000:00:00 00:00:00")) { // System.out.println("...... Datum = " + description + " kann nicht konvertiert // werden"); File f = picture.getFileOriginal(); Date date = new Date(f.lastModified()); picture.meta.setDateImport(date); picture.meta.setDateCurrent(new Date(date.getTime())); return; } // ---------------------------------------------------- // g�ltiges Datum gefunden // ---------------------------------------------------- DateFormat df = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss"); try { myDate = df.parse(description); } catch (ParseException e) { // System.out.println("ParseException fuer Datum = " + description); myDate = new Date(System.currentTimeMillis()); // default } picture.meta.setDateImport(myDate); picture.meta.setDateCurrent(new Date(myDate.getTime())); }
/** * Tries very, very hard to parse the a date. We assume that the text is neither empty nor <code> * null</code>. */ private Date parseDate(String text) { DateFormat formats[] = new DateFormat[] { DateFormat.getDateInstance(DateFormat.SHORT), DateFormat.getDateInstance(DateFormat.MEDIUM), DateFormat.getDateInstance(DateFormat.LONG), DateFormat.getDateInstance(DateFormat.FULL), }; for (int i = 0; i < formats.length; i++) { DateFormat df = formats[i]; try { Date date = df.parse(text); return date; } catch (ParseException ex) { continue; } } error("Could not parse date: " + text); return null; }