📄 changefield.java
字号:
/*
* Copyright (C) 2000, TOA-System Co. All rights reserved.
*/
package util;
import java.util.*;
import java.text.*;
import def.*;
import exce.*;
/**
* 偙偺僋儔僗偼丄宆曄姺傪峴偆僋儔僗偱偡丅<br>
* <pre>
* </pre>
*
* @author Toa System Corporation
* @version 2.0
* @since 2.0
*/
public class ChangeField {
SimpleDateFormat sdf = new SimpleDateFormat(SISnet.DATE_FMT);
public ChangeField() {
}
/**
* String-->int偵曄姺
* @param String String宆偺抣
* @return int int偵曄姺偟偨抣
*/
public int strToInt(String moji) {
try {
int intmoji = Integer.parseInt(moji);
return intmoji;
} catch (NumberFormatException ne) {
throw new ApplicationException("");
} catch (Exception e) {
throw new OriginalException(e);
} finally {
}
}
/**
* String-->int偵曄姺
* @param String String宆偺抣
* @return int int偵曄姺偟偨抣
*/
public int strToInt(String moji, String fieldname) {
try {
int intmoji = Integer.parseInt(moji);
return intmoji;
} catch (NumberFormatException ne) {
throw new ApplicationException(ne, fieldname);
} catch (Exception e) {
throw new OriginalException(e);
} finally {
}
}
/**
* int-->String偵曄姺
* @param Integer String宆偺抣
* @return int int偵曄姺偟偨抣
*/
public String intToStr(int i) {
try {
String moji = Integer.toString(i);
return moji;
} catch (NumberFormatException ne) {
throw new ApplicationException("");
} catch (Exception e) {
throw new OriginalException(e);
} finally {
}
}
/**
* int-->String偵曄姺
* @param Integer String宆偺抣
* @return int int偵曄姺偟偨抣
*/
public String intToStr(int i, String fieldname) {
try {
String moji = Integer.toString(i);
return moji;
} catch (NumberFormatException ne) {
throw new ApplicationException(ne, fieldname);
} catch (Exception e) {
throw new OriginalException(e);
} finally {
}
}
/**
* String-->long偵曄姺
* @param String String宆偺抣
* @return long long偵曄姺偟偨抣
*/
public long strToLong(String moji) {
try {
long longmoji = Long.parseLong(moji);
return longmoji;
} catch (NumberFormatException ne) {
throw new ApplicationException("");
} catch (Exception e) {
throw new OriginalException(e);
} finally {
}
}
/**
* String-->long偵曄姺
* @param String String宆偺抣
* @return long long偵曄姺偟偨抣
*/
public long strToLong(String moji, String fieldname) {
try {
long longmoji = Long.parseLong(moji);
return longmoji;
} catch (NumberFormatException ne) {
throw new ApplicationException(ne, fieldname);
} catch (Exception e) {
throw new OriginalException(e);
} finally {
}
}
/**
* long-->String偵曄姺
* @param Integer String宆偺抣
* @return long long偵曄姺偟偨抣
*/
public String longToStr(long i) {
try {
String moji = Long.toString(i);
return moji;
} catch (NumberFormatException ne) {
throw new ApplicationException("");
} catch (Exception e) {
throw new OriginalException(e);
} finally {
}
}
/**
* long-->String偵曄姺
* @param Integer String宆偺抣
* @return long long偵曄姺偟偨抣
*/
public String longToStr(long i, String fieldname) {
try {
String moji = Long.toString(i);
return moji;
} catch (NumberFormatException ne) {
throw new ApplicationException(ne, fieldname);
} catch (Exception e) {
throw new OriginalException(e);
} finally {
}
}
/**
* String-->double偵曄姺
* @param String String宆偺抣
* @return double double偵曄姺偟偨抣
*/
public double strToDouble(String moji) {
try {
double doublemoji = Double.parseDouble(moji);
return doublemoji;
} catch (NumberFormatException ne) {
throw new ApplicationException("");
} catch (Exception e) {
throw new OriginalException(e);
} finally {
}
}
/**
* String-->double偵曄姺
* @param String String宆偺抣
* @return double double偵曄姺偟偨抣
*/
public double strToDouble(String moji, String fieldname) {
try {
double doublemoji = Double.parseDouble(moji);
return doublemoji;
} catch (NumberFormatException ne) {
throw new ApplicationException(ne, fieldname);
} catch (Exception e) {
throw new OriginalException(e);
} finally {
}
}
/**
* double-->String偵曄姺
* @param Integer String宆偺抣
* @return double long偵曄姺偟偨抣
*/
public String doubleToStr(double i) {
try {
// 2004/08/06 8寘埲忋偺抣偺曄姺帪偵巜悢昞帵偵側傞偨傔曄峏
// String moji = Double.toString(i);
DecimalFormat df = new DecimalFormat();
df.applyPattern(SISnet.DOUBLE_FMT);
String moji = df.format(i);
return moji;
} catch (NumberFormatException ne) {
throw new ApplicationException("");
} catch (Exception e) {
throw new OriginalException(e);
} finally {
}
}
/**
* double-->String偵曄姺
* @param Integer String宆偺抣
* @return double long偵曄姺偟偨抣
*/
public String doubleToStr(double i, String fieldname) {
try {
// 2004/08/06 8寘埲忋偺抣偺曄姺帪偵巜悢昞帵偵側傞偨傔曄峏
// String moji = Double.toString(i);
DecimalFormat df = new DecimalFormat();
df.applyPattern(SISnet.DOUBLE_FMT);
String moji = df.format(i);
return moji;
} catch (NumberFormatException ne) {
throw new ApplicationException(ne, fieldname);
} catch (Exception e) {
throw new OriginalException(e);
} finally {
}
}
/**
* double 宆偐傜暥帤楍傪嶌惉偡傞
* @param double double宆偺悢抣
* string String宆 TANKA:扨壙偺僼僅乕儅僢僩 TANKAS:僇儞儅晅偒扨壙偺僼僅乕儅僢僩
* SURYO:悢検偺僼僅乕儅僢僩 SURYOS:僇儞儅晅偒悢検偺僼僅乕儅僢僩
* KINGAKU:嬥妟乮彮悢揰埲壓側偟乯 KINGAKUS:僇儞儅晅偒嬥妟乮彮悢揰埲壓側偟乯
* @return String 僇儞儅晅偒偺String寢壥
*/
public String strUsing(double dou, String flag) {
try {
DecimalFormat df = new DecimalFormat();
String form = "";
if (flag.equals("TANKA") == true) { //扨壙
form = SISnet.TANKA_FORM;
} else if (flag.equals("TANKAS") == true) { //扨壙S
form = SISnet.TANKAS_FORM;
} else if (flag.equals("SURYO") == true) { //悢検
form = SISnet.SURYO_FORM;
} else if (flag.equals("SURYOS") == true) { //悢検S
form = SISnet.SURYOS_FORM;
} else if (flag.equals("KINGAKU") == true) { //嬥妟
form = SISnet.KINGAKU_FORM;
} else { //嬥妟S
form = SISnet.KINGAKUS_FORM;
}
df.applyPattern(form);
String st = df.format(dou);
return st;
} catch (NumberFormatException ne) {
ne.printStackTrace();
throw new ApplicationException("");
} catch (Exception e) {
throw new OriginalException(e);
} finally {
}
}
/**
* Date-->String偵曄姺
* @param datdate Date宆偺抣
* @return String String偵曄姺偟偨抣
*/
public String dateToStr(java.sql.Date datdate) {
String strdate = null;
try {
if (datdate == null) {
strdate = "";
} else {
strdate = sdf.format(datdate);
}
return strdate;
} catch (NumberFormatException ne) {
throw new ApplicationException("");
} catch (Exception e) {
throw new OriginalException(e);
} finally {
}
}
/**
* Date-->String偵曄姺
* @param datdate Date宆偺抣
* @return String String偵曄姺偟偨抣
*/
public String dateToStr(java.sql.Date datdate, String fieldname) {
String strdate = null;
try {
if (datdate == null) {
strdate = "";
} else {
strdate = sdf.format(datdate);
}
return strdate;
} catch (NumberFormatException ne) {
throw new ApplicationException(ne, fieldname);
} catch (Exception e) {
throw new OriginalException(e);
} finally {
}
}
/**
* Date-->String偵曄姺
* @param datdate Date宆偺抣
* @return String String偵曄姺偟偨抣
*/
public String dateToStr(java.util.Date datdate, String fieldname) {
String strdate = null;
try {
if (datdate == null) {
strdate = "";
} else {
strdate = sdf.format(datdate);
}
return strdate;
} catch (NumberFormatException ne) {
throw new ApplicationException(ne, fieldname);
} catch (Exception e) {
throw new OriginalException(e);
} finally {
}
}
/**
* String-->Date偵曄姺
* @param strdate String宆偺抣
* @return Date Date偵曄姺偟偨抣
*/
public java.sql.Date strToDate(String strdate) {
try {
// 搉偝傟偨暥帤楍(YYYY/MM/DD)傪(YYYY-MM-DD)偺宍偵偡傞
strdate = strdate.replace('/', '-');
java.sql.Date datdate = java.sql.Date.valueOf(strdate);
return datdate;
} catch (IllegalArgumentException iae) {
throw new ApplicationException("");
} catch (Exception e) {
throw new OriginalException(e);
} finally {
}
}
public java.sql.Date strToDate_null(String strdate) {
try {
// 搉偝傟偨暥帤楍(YYYY/MM/DD)傪(YYYY-MM-DD)偺宍偵偡傞
if (strdate == null) {
return null;
}
strdate = strdate.replace('/', '-');
java.sql.Date datdate = java.sql.Date.valueOf(strdate);
return datdate;
} catch (IllegalArgumentException iae) {
throw new ApplicationException("");
} catch (Exception e) {
throw new OriginalException(e);
} finally {
}
}
/**
* String-->Date偵曄姺
* @param strdate String宆偺抣
* @return Date Date偵曄姺偟偨抣
*/
public java.sql.Date strToDate(String strdate, String fieldname) {
try {
// 搉偝傟偨暥帤楍(YYYY/MM/DD)傪(YYYY-MM-DD)偺宍偵偡傞
strdate = strdate.replace('/', '-');
FieldCheck fc = new FieldCheck();
fc.dateCheck(strdate);
java.sql.Date datdate = java.sql.Date.valueOf(strdate);
return datdate;
} catch (IllegalArgumentException iae) {
iae.printStackTrace();
throw new ApplicationException(fieldname);
} catch (ApplicationException ae) {
ae.printStackTrace();
throw new ApplicationException(fieldname, ae.getStatus().errno);
} catch (Exception e) {
e.printStackTrace();
throw new ApplicationException(fieldname);
} finally {
}
}
/**
* Date-->String(Time)偵曄姺
* @param datdate Date宆偺抣
* @return String[4] String偵曄姺偟偨抣
* String[0] HH:MM:SS偺抣
* String[1] HH偺抣
* String[2] MM偺抣
* String[3] SS偺抣
*/
public String[] dateToTime(java.util.Date datdate, String fieldname) {
String[] strdate = new String[4];
Calendar cal = Calendar.getInstance();
// 擔帪偺尩枾側夝愅傪巜掕
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -