FileDocCategorySizeDatePackage
DateTime.javaAPI DocAndroid 1.5 API4279Wed May 06 22:42:46 BST 2009org.apache.james.mime4j.field.datetime

DateTime

public class DateTime extends Object
Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. *

Fields Summary
private final Date
date
private final int
year
private final int
month
private final int
day
private final int
hour
private final int
minute
private final int
second
private final int
timeZone
Constructors Summary
public DateTime(String yearString, int month, int day, int hour, int minute, int second, int timeZone)

        this.year = convertToYear(yearString);
        this.date = convertToDate(year, month, day, hour, minute, second, timeZone);
        this.month = month;
        this.day = day;
        this.hour = hour;
        this.minute = minute;
        this.second = second;
        this.timeZone = timeZone;
    
Methods Summary
public static java.util.DateconvertToDate(int year, int month, int day, int hour, int minute, int second, int timeZone)

        Calendar c = new GregorianCalendar(TimeZone.getTimeZone("GMT+0"));
        c.set(year, month - 1, day, hour, minute, second);
        c.set(Calendar.MILLISECOND, 0);

        if (timeZone != Integer.MIN_VALUE) {
            int minutes = ((timeZone / 100) * 60) + timeZone % 100;
            c.add(Calendar.MINUTE, -1 * minutes);
        }

        return c.getTime();
    
private intconvertToYear(java.lang.String yearString)

        int year = Integer.parseInt(yearString);
        switch (yearString.length()) {
            case 1:
            case 2:
                if (year >= 0 && year < 50)
                    return 2000 + year;
                else
                    return 1900 + year;
            case 3:
                return 1900 + year;
            default:
                return year;
        }
    
public java.util.DategetDate()

        return date;
    
public intgetDay()

        return day;
    
public intgetHour()

        return hour;
    
public intgetMinute()

        return minute;
    
public intgetMonth()

        return month;
    
public intgetSecond()

        return second;
    
public intgetTimeZone()

        return timeZone;
    
public intgetYear()

        return year;
    
public static org.apache.james.mime4j.field.datetime.DateTimeparse(java.lang.String dateString)

        try {
            return new DateTimeParser(new StringReader(dateString)).parseAll();
        }
        catch (TokenMgrError err) {
            throw new ParseException(err.getMessage());
        }
    
public voidprint()

        System.out.println(getYear() + " " + getMonth() + " " + getDay() + "; " + getHour() + " " + getMinute() + " " + getSecond() + " " + getTimeZone());