更新日期:2024年09月11日
com.gbasedbt.lang.IntervalYM 类允许您操纵年-月间隔。
IntervalYM 构造函数
缺省的构造函数定义如下:
public IntervalYM() throws SQLException
如果抛出异常,则请使用该构造函数的第二个版本来显示本地化的错误消息:
public IntervalYM(Connection conn) throws SQLException
请使用下列构造函数来从特定的输入值创建年-月间隔:
•
两个时间戳,返回等于 Timestamp1 - Timestamp2 的 IntervalYM 值:
public IntervalYM(Timestamp t1, Timestamp t2) throws
SQLException
public IntervalYM (Timestamp t1, Timestamp t2, Connectionconn) throws
SQLException
第二个版本允许您支持本地化的错误消息。
•
年和月值(将大型月份值转换为年):
public IntervalYM(int years, int months) throws
SQLException
public IntervalYM(int years, int months,
Connection conn) throws SQLException
第二个版本允许您支持本地化的错误消息。
•
月份值和编码的限定符:
public IntervalYM(int months, short qualifier, Connection conn) throws
SQLException
要指定限定符,可使用 Interval 方法 中描述的 getQualifier() 方法。此构造函数支持
本地化的错误消息。
•
字符串:
public IntervalYM(String string) throws SQLException
public IntervalYM(String string, Connection conn) throws
GBase 8s JDBC Driver 程序员指南
南大通用数据技术股份有限公司
- 113 -
SQLException
第二个版本允许您支持本地化的错误消息。
•
字符串和限定符:
public IntervalYM(String string, short qualifier, Connection conn) throws
SQLException
要指定限定符,可使用 Interval 方法 中描述的 getQualifier() 方法。此构造函数支持
本地化的错误消息。
•
字符和限定符信息:
public IntervalYM(String string, int length, byte startCode, byte endCode)
throws SQLException
public IntervalYM(String string, int length, byte startCode, byte endCode,
Connection conn) throws SQLException
第二个版本允许您支持本地化的错误消息。
IntervalYM 方法
下列方法允许您操纵年-月间隔。(您还可使用前面描述的 Interval 方法。)您可
以 IntervalYM 方法执行的某些任务包括下列:
•
比较两个间隔:
boolean equals(Object other)
boolean greaterThan(IntervalYM other)
boolean lessThan(IntervalYM other)
•
从其设置间隔的值:
ₒ
字符串:
void fromString(String other)
void set(String string)
ₒ
年和月值(将大型月值转换为年):
void set(int years, int months)
ₒ
两个时间戳:
void set(Timestamp t1, Timestamp t2)
•
设置间隔的限定符:
ₒ
从长度、开始代码和结束代码:
void setQualifier(int length, byte startcode, byte endcode)
ₒ
使用现有的限定符:
GBase 8s JDBC Driver 程序员指南
南大通用数据技术股份有限公司
- 114 -
void setQualifier(short qualifier)
•
取得间隔中的月数:
long getMonths()
•
以 yyyy-mm 格式来创建间隔的字符串表示:
String toString()
字段的显示依赖于限定符。以空格替代开头的零。