DateFormats + now(), today()

master
mjkhan21 6 months ago
parent 709589106f
commit a24cde0327

@ -0,0 +1,114 @@
package cokr.xit.foundation.data;
import cokr.xit.foundation.Assert;
public class DataProc {
public static enum Type {
/** 데이터 생성 */
CREATE("C"),
/** 데이터 수정 */
UPDATE("U"),
/** 데이터 삭제 */
DELETE("D");
private final String code;
private Type(String code) {
this.code = code;
}
/** .
* @return
*/
public String getCode() {
return code;
}
/** Type .
* @param code
* @return DataProc
*/
public static Type codeOf(String code) {
if (Assert.isEmpty(code))
return null;
for (Type type: values()) {
if (type.code.equals(code))
return type;
}
throw new IllegalArgumentException("code: " + code);
}
}
private Type type;
private Object target;
private Boolean success;
private String message;
private DataObject info;
private Throwable error;
public Type getType() {
return type;
}
public DataProc setType(Type type) {
this.type = type;
return this;
}
@SuppressWarnings("unchecked")
public <T> T getTarget() {
return (T)target;
}
public DataProc setTarget(Object target) {
this.target = target;
return this;
}
public boolean isSuccess() {
return error == null
&& Boolean.TRUE.equals(Assert.ifEmpty(success, Boolean.TRUE));
}
public DataProc setSuccess(boolean success) {
this.success = success;
return this;
}
public String getMessage() {
return message;
}
public DataProc setMessage(String message) {
this.message = message;
return this;
}
public DataObject getInfo() {
return info;
}
@SuppressWarnings("unchecked")
public <T> T getInfo(String key) {
if (info == null) return null;
return (T)info.get(key);
}
public DataProc setInfo(String key, Object obj) {
if (info == null)
info = new DataObject();
info.put(key, obj);
return this;
}
public Throwable getError() {
return error;
}
public DataProc setError(Throwable error) {
this.error = Assert.rootCause(error);
return this;
}
}

@ -1,44 +0,0 @@
package cokr.xit.foundation.data;
import cokr.xit.foundation.Assert;
/**
* @author mjkhan
*/
public enum ProcType {
/** 데이터 생성 */
CREATE("C"),
/** 데이터 수정 */
UPDATE("U"),
/** 데이터 삭제 */
DELETE("D");
private final String code;
private ProcType(String code) {
this.code = code;
}
/** .
* @return
*/
public String getCode() {
return code;
}
/** ProcType .
* @param code
* @return ProcType
*/
public static ProcType codeOf(String code) {
if (Assert.isEmpty(code))
return null;
for (ProcType procType: values()) {
if (procType.code.equals(code))
return procType;
}
throw new IllegalArgumentException("code: " + code);
}
}

@ -18,6 +18,14 @@ public class DateFormats {
return dateFormat(pattern).format(date);
}
public String now() {
return format("yyyyMMddHHmmss", System.currentTimeMillis());
}
public String today() {
return now().substring(0, 8);
}
public Date parse(String pattern, String str) {
if (Assert.isEmpty(str)) return null;

Loading…
Cancel
Save