content: /*
   * IFD_9004_DateTimeDigitized.java    Oct 16, 2010, 14:59
   *
   * Copyright 2010, BinaryInternals.org. All rights reserved.
   * Use is subject to license terms.
   */
  package org.binaryinternals.format.jpeg.tiff;
  
  import java.io.IOException;
  import java.util.Calendar;
  import javax.swing.tree.DefaultMutableTreeNode;
  import org.binaryinternals.commonlib.core.PosDataInputStream;
  import org.binaryinternals.commonlib.core.FileFormatException;
  
  /**
   *
   * @author Amos Shi
   * @see IFD_8769_Exif#CATEGORY_F
   */
  public class IFD_9004_DateTimeDigitized extends IFD_ASCII {
  
      public static final int COUNT = 20;
      public final Calendar datetime;
  
      public IFD_9004_DateTimeDigitized(final PosDataInputStream pDIS, int byteOrder, int tag, int startPosTiff, byte[] byteArrayTiff)
              throws IOException, FileFormatException {
          super(pDIS, byteOrder, tag, startPosTiff, byteArrayTiff);
          super.checkIFDCount(COUNT);
  
          final PosDataInputStream reader = super.getTiffOffsetReader();
          final byte[] buf = new byte[IFD_9004_DateTimeDigitized.COUNT];
          reader.readFully(buf, 0, IFD_9004_DateTimeDigitized.COUNT);
          this.datetime = IFD_0132_DateTime.buf2calendar(buf);
      }
  
      @Override
      public boolean isValue() {
          return false;
      }
  
      @Override
      public void generateTreeNode(DefaultMutableTreeNode parentNode) {
          super.generateTreeNode_ASCII(
                  parentNode,
                  String.format("%04d:%02d:%02d %02d:%02d:%02d",
                  this.datetime.get(Calendar.YEAR),
                  this.datetime.get(Calendar.MONTH),
                  this.datetime.get(Calendar.DATE),
                  this.datetime.get(Calendar.HOUR_OF_DAY),
                  this.datetime.get(Calendar.MINUTE),
                  this.datetime.get(Calendar.SECOND)),
                  IFDMessage.getString(IFDMessage.KEY_IFD_9004_Description) + IFDMessage.getString(IFDMessage.KEY_IFD_8769_Exif_Category_F));
      }
  }
  