cn.cuizuoli.gotour.model.Common.java Source code

Java tutorial

Introduction

Here is the source code for cn.cuizuoli.gotour.model.Common.java

Source

/*
 * Copyright 2014 the original author or authors.
 *
 * Licensed 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.
 */
package cn.cuizuoli.gotour.model;

import java.io.Serializable;
import java.util.Date;

import lombok.Data;

import org.apache.commons.lang.StringUtils;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

/**
 * Common
 * @author cuizuoli
 */
@Data
abstract class Common implements Serializable {
    /**
     * 
     */
    private static final long serialVersionUID = -8851536436316482918L;
    private static DateTimeFormatter DATETIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm");
    private boolean checked = false;
    private String creator;
    private String modifier;
    private Date createTime;
    private Date modifyTime;
    private String activeYn;

    public String getCreateTimeFormat() {
        if (createTime != null) {
            return new DateTime(createTime.getTime()).toString(DATETIME_FORMATTER);
        }
        return StringUtils.EMPTY;
    }

    public String getModifyTimeFormat() {
        if (modifyTime != null) {
            return new DateTime(modifyTime.getTime()).toString(DATETIME_FORMATTER);
        }
        return StringUtils.EMPTY;
    }

    public void setCreateTimeFormat(String createTimeFormat) {
        setCreateTime(DATETIME_FORMATTER.parseDateTime(createTimeFormat).toDate());
    }

    public void setModifyTimeFormat(String modifyTimeFormat) {
        setModifyTime(DATETIME_FORMATTER.parseDateTime(modifyTimeFormat).toDate());
    }

}