Skip to content

Commit

Permalink
Merge pull request #366 from kwhopper/NikonType2_getPowerUpTimeDescri…
Browse files Browse the repository at this point in the history
…ption

Fix NikonType2 getPowerUpTimeDescription
  • Loading branch information
drewnoakes authored Oct 2, 2018
2 parents 79de6b0 + d12d26a commit 47e2bff
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.drew.lang.annotations.Nullable;
import com.drew.metadata.TagDescriptor;

import java.nio.ByteBuffer;
import java.text.DecimalFormat;

import static com.drew.metadata.exif.makernotes.NikonType2MakernoteDirectory.*;
Expand Down Expand Up @@ -104,7 +105,15 @@ public String getDescription(int tagType)
@Nullable
public String getPowerUpTimeDescription()
{
return getEpochTimeDescription(TAG_POWER_UP_TIME);
// this is generally a byte[] of length 8 directly representing a date and time.
// the format is : first 2 bytes together are the year, and then each byte after
// is month, day, hour, minute, second with the eighth byte unused
// e.g., 2011:04:25 01:54:58

byte[] values = _directory.getByteArray(TAG_POWER_UP_TIME);
short year = ByteBuffer.wrap(new byte[]{values[0], values[1]}).getShort();
return String.format("%04d:%02d:%02d %02d:%02d:%02d", year, values[2], values[3],
values[4], values[5], values[6]);
}

@Nullable
Expand Down

0 comments on commit 47e2bff

Please sign in to comment.