Source code: com/sixlegs/image/png/Chunk_tIME.java
1 // Copyright (C) 1998, 1999, 2001 Chris Nokleberg
2 // Please see included LICENSE.TXT
3
4 package com.sixlegs.image.png;
5
6 import java.io.IOException;
7 import java.util.Calendar;
8 import java.util.TimeZone;
9
10 final class Chunk_tIME
11 extends Chunk
12 {
13 Chunk_tIME()
14 {
15 super(tIME);
16 }
17
18 protected boolean multipleOK()
19 {
20 return false;
21 }
22
23 protected void readData()
24 throws IOException
25 {
26 TimeZone tz = TimeZone.getDefault();
27 tz.setRawOffset(0);
28 Calendar cal = Calendar.getInstance(tz);
29 int year = in_data.readUnsignedShort();
30 int month = in_data.readUnsignedByte();
31 int day = in_data.readUnsignedByte();
32 int hour = in_data.readUnsignedByte();
33 int minute = in_data.readUnsignedByte();
34 int second = in_data.readUnsignedByte();
35 if (month > 12 || day > 31 || hour > 23 || minute > 59 || second > 60 ||
36 month < 1 || day < 1 || hour < 0 || minute < 0 || second < 0)
37 throw new PngExceptionSoft("Bad tIME data; index out of bounds");
38 cal.set(year, month - 1, day, hour, minute, second);
39
40 img.data.properties.put("time", cal.getTime());
41 }
42 }