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.
- the code run [catch (exception e)] part if did not edit image date previously.
- 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 =)
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
Post a Comment