Newer
Older
dxcgt / app / src / main / java / com / smartdot / cgt / model / MessageModel.java
wangxitong on 6 Apr 2021 3 KB first commit
package com.smartdot.cgt.model;

import java.text.SimpleDateFormat;
import java.util.Date;

import android.util.Log;

import com.smartdot.cgt.util.StringUtils;

public class MessageModel extends BaseModel {
    /**
	 * 
	 */
    private static final long serialVersionUID = 1L;

    protected String id;

    protected String author;

    protected String publishTime;

    protected String publishTimeDate;

    protected String publishTimeTime;

    protected String title;

    protected String content;

    protected Boolean isread;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    /**
     * @return the author
     */
    public String getAuthor() {
        return author;
    }

    /**
     * @param author
     *            the author to set
     */
    public void setAuthor(String author) {
        this.author = author;
    }

    public String getPublishTimeDate() {
        if (publishTimeDate == null) {
            try {
                if (!StringUtils.isNullOrEmpty(publishTime)) {
                    Date datetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(publishTime.substring(0, 19));
                    publishTimeDate = new SimpleDateFormat("M月d日").format(datetime);
                } else {
                    publishTimeDate = "";
                }
            } catch (Exception e) {
                Log.w("message_publishTime", "transform failed!");
                publishTimeDate = "";
            }
        }
        return publishTimeDate;
    }

    public String getPublishTimeTime() {
        if (publishTimeTime == null) {
            try {
                if (!StringUtils.isNullOrEmpty(publishTime)) {
                    Date datetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(publishTime.substring(0, 19));
                    publishTimeTime = new SimpleDateFormat("HH:mm").format(datetime);
                } else {
                    publishTimeTime = "";
                }
            } catch (Exception e) {
                Log.w("message_publishTime", "transform failed!");
                publishTimeTime = "";
            }
        }
        return publishTimeTime;
    }

    /**
     * @return the publishTime
     */
    public String getPublishTime() {
        return publishTime;
    }

    /**
     * @param publishtime
     *            the publishTime to set
     */
    public void setPublishTime(String publishTime) {
        this.publishTime = publishTime;
    }

    /**
     * @return the title
     */
    public String getTitle() {
        return title;
    }

    /**
     * @param title
     *            the title to set
     */
    public void setTitle(String title) {
        this.title = title;
    }

    /**
     * @return the content
     */
    public String getContent() {
        return content;
    }

    /**
     * @param content
     *            the content to set
     */
    public void setContent(String content) {
        this.content = content;
    }

    public Boolean getIsread() {
        return isread;
    }

    public Boolean getUnRead() {
        return !isread;
    }

    public void setIsread(Boolean isread) {
        this.isread = isread;
    }

}