isNotEmpty 추가
This commit is contained in:
parent
844fa12cb7
commit
6c64f0b3a9
@ -1,89 +1,99 @@
|
||||
package nlib.util;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Locale;
|
||||
|
||||
import egovframework.com.utl.fcc.service.EgovStringUtil;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* @Class Name : StringUtil.java
|
||||
*
|
||||
* @Description : 문자열 관련 공통 함수 모음
|
||||
*
|
||||
*
|
||||
* @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @ ------------ -------- ---------------------------
|
||||
* @ 수정일 수정자 수정내용
|
||||
* @ ------------ -------- ---------------------------
|
||||
* @ 2021. 6. 22. KNKIM 최초 생성
|
||||
*
|
||||
*
|
||||
* @author 이씨플라자 * DIGITALSHIP KNKIM
|
||||
* @since 2021. 6. 22.
|
||||
* @version 1.0
|
||||
*
|
||||
*/
|
||||
public class StringUtil extends EgovStringUtil {
|
||||
|
||||
/**
|
||||
* Null 이거나, 빈문자열(공백 포함)인 경우, true를 리턴한다.
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static boolean isEmpty(String str) {
|
||||
return str == null || str.trim().length() == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 문자열을 정수형으로 변환하여 리턴한다. 만일 문자열이 null 또는 빈 문자열인 경우, -1을 리턴한다.
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static int toNumber(String str) {
|
||||
return toNumber(str, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 문자열을 정수형으로 변환하여 리턴한다. 만일 문자열이 null 또는 빈 문자열인 경우, 기본값 정보 defaultInt를 리턴한다.
|
||||
*
|
||||
* @param str
|
||||
* @param defaultInt
|
||||
* @return
|
||||
*/
|
||||
public static int toNumber(String str, int defaultInt) {
|
||||
if(isEmpty(str)) return defaultInt;
|
||||
|
||||
try {
|
||||
return Integer.parseInt(str.trim());
|
||||
} catch(Exception e) {}
|
||||
|
||||
return defaultInt;
|
||||
}
|
||||
|
||||
/**
|
||||
* 현재 시각을 yyyyMMddhhmmssSSS 형식으로 리턴한다.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getTimeStamp() {
|
||||
|
||||
String rtnStr = null;
|
||||
|
||||
// 문자열로 변환하기 위한 패턴 설정(년도-월-일 시:분:초:초(자정이후 초))
|
||||
String pattern = "yyyyMMddhhmmssSSS";
|
||||
|
||||
SimpleDateFormat sdfCurrent = new SimpleDateFormat(pattern, Locale.KOREA);
|
||||
Timestamp ts = new Timestamp(System.currentTimeMillis());
|
||||
|
||||
rtnStr = sdfCurrent.format(ts.getTime());
|
||||
|
||||
return rtnStr;
|
||||
}
|
||||
}
|
||||
package nlib.util;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Locale;
|
||||
|
||||
import egovframework.com.utl.fcc.service.EgovStringUtil;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* @Class Name : StringUtil.java
|
||||
*
|
||||
* @Description : 문자열 관련 공통 함수 모음
|
||||
*
|
||||
*
|
||||
* @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @ ------------ -------- ---------------------------
|
||||
* @ 수정일 수정자 수정내용
|
||||
* @ ------------ -------- ---------------------------
|
||||
* @ 2021. 6. 22. KNKIM 최초 생성
|
||||
*
|
||||
*
|
||||
* @author 이씨플라자 * DIGITALSHIP KNKIM
|
||||
* @since 2021. 6. 22.
|
||||
* @version 1.0
|
||||
*
|
||||
*/
|
||||
public class StringUtil extends EgovStringUtil {
|
||||
|
||||
/**
|
||||
* Null 이거나, 빈문자열(공백 포함)인 경우, true를 리턴한다.
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static boolean isEmpty(String str) {
|
||||
return str == null || str.trim().length() == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Null이 아니고 빈문자열(공백 포함)이 아닌 일반 문자가 존재하는 , true를 리턴한다.
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static boolean isNotEmpty(String str) {
|
||||
return !isEmpty(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 문자열을 정수형으로 변환하여 리턴한다. 만일 문자열이 null 또는 빈 문자열인 경우, -1을 리턴한다.
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static int toNumber(String str) {
|
||||
return toNumber(str, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 문자열을 정수형으로 변환하여 리턴한다. 만일 문자열이 null 또는 빈 문자열인 경우, 기본값 정보 defaultInt를 리턴한다.
|
||||
*
|
||||
* @param str
|
||||
* @param defaultInt
|
||||
* @return
|
||||
*/
|
||||
public static int toNumber(String str, int defaultInt) {
|
||||
if(isEmpty(str)) return defaultInt;
|
||||
|
||||
try {
|
||||
return Integer.parseInt(str.trim());
|
||||
} catch(Exception e) {}
|
||||
|
||||
return defaultInt;
|
||||
}
|
||||
|
||||
/**
|
||||
* 현재 시각을 yyyyMMddhhmmssSSS 형식으로 리턴한다.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getTimeStamp() {
|
||||
|
||||
String rtnStr = null;
|
||||
|
||||
// 문자열로 변환하기 위한 패턴 설정(년도-월-일 시:분:초:초(자정이후 초))
|
||||
String pattern = "yyyyMMddhhmmssSSS";
|
||||
|
||||
SimpleDateFormat sdfCurrent = new SimpleDateFormat(pattern, Locale.KOREA);
|
||||
Timestamp ts = new Timestamp(System.currentTimeMillis());
|
||||
|
||||
rtnStr = sdfCurrent.format(ts.getTime());
|
||||
|
||||
return rtnStr;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user