001/**
002 * Copyright 2011 Bill Brown
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package com.colorfulsoftware.rss;
017
018import java.io.Serializable;
019import java.util.Date;
020
021/**
022 * <p>
023 * The &lt;lastBuildDate> element.
024 * </p>
025 * <p>
026 * From the <a href="http://cyber.law.harvard.edu/rss/rss.html">RSS 2.0
027 * specification</a>...
028 * </p>
029 * <p>
030 * The last time the content of the channel changed.
031 * </p>
032 * 
033 * @author Bill Brown
034 * 
035 */
036public class LastBuildDate implements Serializable {
037
038        private static final long serialVersionUID = -8692371191911347659L;
039
040        private final RSSDateConstruct lastBuildDate;
041
042        LastBuildDate(String lastBuildDate) throws RSSpectException {
043                this.lastBuildDate = new RSSDateConstruct(lastBuildDate);
044        }
045
046        LastBuildDate(Date lastBuildDate) {
047                this.lastBuildDate = new RSSDateConstruct(lastBuildDate);
048        }
049
050        /**
051         * 
052         * @return the date timestamp for this element.
053         */
054        public Date getDateTime() {
055                return lastBuildDate.getDateTime();
056        }
057
058        /**
059         * 
060         * @return the string formated version of the time for example
061         *         2006-04-28T12:50:43.337-05:00
062         */
063        public String getText() {
064                return lastBuildDate.getText();
065        }
066
067        /**
068         * Shows the contents of the &lt;lastBuildDate> element.
069         */
070        @Override
071        public String toString() {
072                return "<lastBuildDate>" + lastBuildDate + "</lastBuildDate>";
073        }
074        
075        @Override
076        public boolean equals(Object obj) {
077                if (obj == this) {
078                        return true;
079                }
080                if (!(obj instanceof LastBuildDate)) {
081                        return false;
082                }
083                return this.toString().equals(obj.toString());
084        }
085        
086        @Override public int hashCode() {
087                return toString().hashCode();
088        }
089}