getCreated_at
last analyzed

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 2
1
package com.base.Models;
2
3
import java.text.ParseException;
4
import java.text.SimpleDateFormat;
5
import java.util.Date;
6
7
public class BaseModel {
8
9
    /**
10
     * Model id
11
     */
12
    protected int id;
13
14
    /**
15
     * Model created_at
16
     */
17
    protected String created_at;
18
19
    /**
20
     * Model updated_at
21
     */
22
    protected String updated_at;
23
24
    /**
25
     * Model Pattern for Data
26
     */
27
    private String expectedPattern = "y-M-d H:m:s";
28
29
    /**
30
     * Return Model d
31
     *
32
     * @return Model Id
33
     */
34
    public int getId() {
35
        return id;
36
    }
37
38
    /**
39
     * Set Model Id
40
     *
41
     * @param id
42
     * @return
43
     */
44
    public BaseModel setId(int id) {
45
        this.id = id;
46
        return this;
47
    }
48
49
    /**
50
     * Return Model Created_at
51
     *
52
     * @return Date
53
     */
54
    public Date getCreated_at() {
0 ignored issues
show
Coding Style introduced by
As per the Java conventions, method names should start with a lowercase letter followed by lower and upper case letters and digits. Use camel case to denote new words in the method name.
Loading history...
55
        return this.makeDate(this.created_at);
56
    }
57
58
    /**
59
     * Set Model Created Date
60
     *
61
     * @param created_at
62
     * @return
63
     */
64
    public BaseModel setCreated_at(String created_at) {
0 ignored issues
show
Coding Style introduced by
As per the Java conventions, method names should start with a lowercase letter followed by lower and upper case letters and digits. Use camel case to denote new words in the method name.
Loading history...
65
        this.created_at = created_at;
66
        return this;
67
    }
68
69
    /**
70
     * Return Model Updated_at
71
     *
72
     * @return Date
73
     */
74
    public Date getUpdated_at() {
0 ignored issues
show
Coding Style introduced by
As per the Java conventions, method names should start with a lowercase letter followed by lower and upper case letters and digits. Use camel case to denote new words in the method name.
Loading history...
75
        return this.makeDate(this.created_at);
76
    }
77
78
    /**
79
     * Set Model Updated Date
80
     *
81
     * @param updated_at
82
     * @return
83
     */
84
    public BaseModel setUpdated_at(String updated_at) {
0 ignored issues
show
Coding Style introduced by
As per the Java conventions, method names should start with a lowercase letter followed by lower and upper case letters and digits. Use camel case to denote new words in the method name.
Loading history...
85
        this.updated_at = updated_at;
86
        return this;
87
    }
88
89
    /**
90
     * Genrate Data from String and Return it.
91
     *
92
     * @param dateTime
93
     * @return
94
     */
95
    private Date makeDate(String dateTime) {
96
        SimpleDateFormat formatter = new SimpleDateFormat(this.expectedPattern);
97
        try {
98
            Date date = formatter.parse(dateTime);
99
            return date;
100
        } catch (ParseException e) {
101
            return new Date();
102
        }
103
    }
104
}
105