XMPDateTimeImpl.java
5.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.internal.xmp.impl;
import com.adobe.internal.xmp.XMPDateTime;
import com.adobe.internal.xmp.XMPException;
import com.adobe.internal.xmp.impl.ISO8601Converter;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.TimeZone;
public class XMPDateTimeImpl
implements XMPDateTime {
private int year = 0;
private int month = 0;
private int day = 0;
private int hour = 0;
private int minute = 0;
private int second = 0;
private TimeZone timeZone = null;
private int nanoSeconds;
private boolean hasDate = false;
private boolean hasTime = false;
private boolean hasTimeZone = false;
public XMPDateTimeImpl() {
}
public XMPDateTimeImpl(Calendar calendar) {
Date date = calendar.getTime();
TimeZone zone = calendar.getTimeZone();
GregorianCalendar intCalendar = (GregorianCalendar)Calendar.getInstance(Locale.US);
intCalendar.setGregorianChange(new Date(Long.MIN_VALUE));
intCalendar.setTimeZone(zone);
intCalendar.setTime(date);
this.year = intCalendar.get(1);
this.month = intCalendar.get(2) + 1;
this.day = intCalendar.get(5);
this.hour = intCalendar.get(11);
this.minute = intCalendar.get(12);
this.second = intCalendar.get(13);
this.nanoSeconds = intCalendar.get(14) * 1000000;
this.timeZone = intCalendar.getTimeZone();
this.hasTimeZone = true;
this.hasTime = true;
this.hasDate = true;
}
public XMPDateTimeImpl(Date date, TimeZone timeZone) {
GregorianCalendar calendar = new GregorianCalendar(timeZone);
calendar.setTime(date);
this.year = calendar.get(1);
this.month = calendar.get(2) + 1;
this.day = calendar.get(5);
this.hour = calendar.get(11);
this.minute = calendar.get(12);
this.second = calendar.get(13);
this.nanoSeconds = calendar.get(14) * 1000000;
this.timeZone = timeZone;
this.hasTimeZone = true;
this.hasTime = true;
this.hasDate = true;
}
public XMPDateTimeImpl(String strValue) throws XMPException {
ISO8601Converter.parse(strValue, this);
}
public int getYear() {
return this.year;
}
public void setYear(int year) {
this.year = Math.min(Math.abs(year), 9999);
this.hasDate = true;
}
public int getMonth() {
return this.month;
}
public void setMonth(int month) {
this.month = month < 1 ? 1 : (month > 12 ? 12 : month);
this.hasDate = true;
}
public int getDay() {
return this.day;
}
public void setDay(int day) {
this.day = day < 1 ? 1 : (day > 31 ? 31 : day);
this.hasDate = true;
}
public int getHour() {
return this.hour;
}
public void setHour(int hour) {
this.hour = Math.min(Math.abs(hour), 23);
this.hasTime = true;
}
public int getMinute() {
return this.minute;
}
public void setMinute(int minute) {
this.minute = Math.min(Math.abs(minute), 59);
this.hasTime = true;
}
public int getSecond() {
return this.second;
}
public void setSecond(int second) {
this.second = Math.min(Math.abs(second), 59);
this.hasTime = true;
}
public int getNanoSecond() {
return this.nanoSeconds;
}
public void setNanoSecond(int nanoSecond) {
this.nanoSeconds = nanoSecond;
this.hasTime = true;
}
public int compareTo(Object dt) {
long d = this.getCalendar().getTimeInMillis() - ((XMPDateTime)dt).getCalendar().getTimeInMillis();
if (d != 0) {
return (int)Math.signum(d);
}
d = this.nanoSeconds - ((XMPDateTime)dt).getNanoSecond();
return (int)Math.signum(d);
}
public TimeZone getTimeZone() {
return this.timeZone;
}
public void setTimeZone(TimeZone timeZone) {
this.timeZone = timeZone;
this.hasTime = true;
this.hasTimeZone = true;
}
public boolean hasDate() {
return this.hasDate;
}
public boolean hasTime() {
return this.hasTime;
}
public boolean hasTimeZone() {
return this.hasTimeZone;
}
public Calendar getCalendar() {
GregorianCalendar calendar = (GregorianCalendar)Calendar.getInstance(Locale.US);
calendar.setGregorianChange(new Date(Long.MIN_VALUE));
if (this.hasTimeZone) {
calendar.setTimeZone(this.timeZone);
}
calendar.set(1, this.year);
calendar.set(2, this.month - 1);
calendar.set(5, this.day);
calendar.set(11, this.hour);
calendar.set(12, this.minute);
calendar.set(13, this.second);
calendar.set(14, this.nanoSeconds / 1000000);
return calendar;
}
public String getISO8601String() {
return ISO8601Converter.render(this);
}
public String toString() {
return this.getISO8601String();
}
}