1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package com.vci.server.base.persistence.dao;
 
import java.text.SimpleDateFormat;
 
import com.vci.common.objects.UserEntity;
 
/**
 * <p>Title: Hibernate服务公用类</p>
 * <p>Description: 通过共有类完成用户信息的设置,为操作记录日志做准备</p>
 * <p>Copyright: Copyright (c) 2011</p>
 * <p>Company: VCI</p>
 * @author Administrator
 * @time 2011-6-16
 * @version 1.0
 */
public class BaseService {
 
    protected UserEntity userEntity = null;
    
    protected SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
    
    public BaseService() {
        
    }
    
    public BaseService(UserEntity userEntity){
        this.userEntity = userEntity;
    }
    
    public void setUserEntity(UserEntity userEntity) {
        this.userEntity = userEntity;
    }
    
    public UserEntity getUserEntity() {
        return this.userEntity;
    }
    
    /**
     * 返回日期的字符串表现形式
     * <p>Description: </p>
     * 
     * @author xchao
     * @time 2012-5-19
     * @param date java.util.Date
     * @return
     */
    public String getDateString(java.util.Date date){
        return SDF.format(date);
    }
    /**
     * 
     * <p>Description: </p>
     * 
     * @author xchao
     * @time 2012-5-19
     * @param date java.sql.Date
     * @return
     */
    public String getDateString(java.sql.Date date){
        @SuppressWarnings("deprecation")
        java.util.Date utDate = new java.util.Date(
                date.getYear(), date.getMonth(), date.getDate(),
                date.getHours(), date.getMinutes(), date.getSeconds());
        return getDateString(utDate);
    }
}