Subversion Repositories XServices

Rev

Rev 103 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
103 brianR 1
/*
2
 *   Copyright 2013 Brian Rosenberger (Brutex Network)
3
 *
4
 *   Licensed under the Apache License, Version 2.0 (the "License");
5
 *   you may not use this file except in compliance with the License.
6
 *   You may obtain a copy of the License at
7
 *
8
 *       http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 *   Unless required by applicable law or agreed to in writing, software
11
 *   distributed under the License is distributed on an "AS IS" BASIS,
12
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 *   See the License for the specific language governing permissions and
14
 *   limitations under the License.
15
 */
16
 
17
package net.brutex.xservices.types.ant;
18
 
19
import java.util.Date;
20
import java.util.GregorianCalendar;
21
import java.util.TimeZone;
22
import javax.xml.bind.annotation.XmlElement;
23
import javax.xml.bind.annotation.XmlType;
24
import net.brutex.xservices.types.DateFormatType;
25
 
26
/**
27
 * @author Brian Rosenberger, bru(at)brutex.de
28
 *
29
 */
30
@XmlType(name="DateInfoType", namespace="http://ws.xservices.brutex.net", propOrder={"isoDate", "rfcDate", "millis"})
31
public class DateInfoType
32
{
33
  public static final String XML_NAME = "DateInfoType";
34
  private final GregorianCalendar date;
35
  private final TimeZone zone;
36
 
37
  public DateInfoType(GregorianCalendar date, TimeZone zone)
38
  {
39
    this.date = date;
40
    this.zone = zone;
41
  }
42
 
43
  public DateInfoType()
44
  {
45
    this.zone = TimeZone.getDefault();
46
    this.date = new GregorianCalendar(this.zone);
47
  }
48
 
49
  @XmlElement(name="timestamp")
50
  public long getMillis()
51
  {
52
    return this.date.getTimeInMillis();
53
  }
54
 
55
  @XmlElement(name="iso8601date")
56
  public Date getIsoDate()
57
  {
58
    return this.date.getTime();
59
  }
60
 
61
  @XmlElement(name="rfc822date")
62
  public String getRfcDate()
63
  {
64
    return DateFormatType.RFC822.format(this.date.getTime(), null, null);
65
  }
66
}