java - Javafx Get Image Date Information -


i using javafx wish retrieve information of image date, size, format etc. below partial code use retrieve image date.

i able retrieve date information image file, getting issue.

  1. the code run [catch (exception e)] part if did not edit image date previously.
  2. if did edit date example below, code work without go [catch (exception e)].

i cant't figure out reason cause happen. please give suggestion fix code bug or logic issue within code? in advance =)

image date original

image date edited

date date = null;             try {              file imagefile = new file(path);             metadata metadata = imagemetadatareader.readmetadata(imagefile);             exifsubifddirectory directory = metadata.getfirstdirectoryoftype(exifsubifddirectory.class);                 if (directory!=null) {                     // read date                  date = directory.getdate( exifsubifddirectory.tag_datetime_original );                 dateformat df = dateformat.getdateinstance();                 df.format( date );                 int year = df.getcalendar().get( calendar.year );                 int month = df.getcalendar().get( calendar.month ) + 1;                 int day = df.getcalendar().get(calendar.day_of_month);                  system.out.println( "year: " + year + ", month: " + month );                 system.out.println("day:"+day);                  system.out.println( "date: " + date );                                        } else {                         system.out.println( "exif null" );                     }                 } catch (exception e) {                 system.out.println("date format cannot read exception");             }   


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -