Java Parse Date Pattern YYYY parseEXIFFormat(String dateString)

Here you can find the source of parseEXIFFormat(String dateString)

Description

parse EXIF Format

License

Open Source License

Declaration

public static Date parseEXIFFormat(String dateString) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    public static Date parseEXIFFormat(String dateString) {
        /* from metadataextractor */
        // This seems to cover all known Exif date strings
        // Note that "    :  :     :  :  " is a valid date string according to the Exif spec (which means 'unknown date'): http://www.awaresystems.be/imaging/tiff/tifftags/privateifd/exif/datetimeoriginal.html
        String datePatterns[] = { "yyyy:MM:dd HH:mm:ss", "yyyy:MM:dd HH:mm", "yyyy-MM-dd HH:mm:ss",
                "yyyy-MM-dd HH:mm", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm" };
        for (String datePattern : datePatterns) {
            try {
                /* current timezone */
                DateFormat parser = new SimpleDateFormat(datePattern);
                return parser.parse(dateString);
            } catch (ParseException ex) {
                // simply try the next pattern
            }/*from w  w  w.j  a v a 2 s .co m*/
        }
        return null;
    }
}

Related

  1. parseDisplay4Key(Object date)
  2. parseDT(String fmt, String timeline)
  3. parseDueDate(String date)
  4. parseEapoDate(String date)
  5. parseEuropeanDateAnd12HrsTimeString(String aDateString, String aTimeString)
  6. parseExpireField(String timestring)
  7. parseFormattedTime(String formattedTime)
  8. parseFTPDate(String dateStr)
  9. parseFullDate(String paramName, String dateStr)