public String substring(int beginIndex, int endIndex) Returns a new string that is a substring of this string. The substring begins at the specified beginIndex and extends to the character at index endIndex - 1. Thus the length of the substring is endIndex-beginIndex.Examples: "hamburger".substring(4, 8) returns "urge" "smiles".substring(1, 5) returns "mile"
Parameters:beginIndex - the beginning index, inclusive. endIndex - the ending index, exclusive.Returns:the specified substring.Throws:IndexOutOfBoundsException - if the beginIndex is negative, or endIndex is larger than the length of this String object, or beginIndex is larger than endIndex.
int endIndex)
Returns a new string that is a substring of this string. The substring begins at the specified beginIndex and extends to the character at index endIndex - 1. Thus the length of the substring is endIndex-beginIndex.Examples:
"hamburger".substring(4, 8) returns "urge"
"smiles".substring(1, 5) returns "mile"
Parameters:beginIndex - the beginning index, inclusive.
endIndex - the ending index, exclusive.Returns:the specified substring.Throws:IndexOutOfBoundsException - if the beginIndex is negative, or endIndex is larger than the length of this String object, or beginIndex is larger than endIndex.
System.out.println(str.subString(0,8));
System.out.println(str.subString(8));
String str="YYYYMMDDYYYYMMDD";
System.out.println(str.trim().subString(a,b));a开始的字符的位置,B结束的位置
way 2:
自己写一方法
public String SubString(String Str,int start,int end)
{
String Str1;
int Len=Str.length();
if((end-start)>Len)
{
return "";
}
for(int i=0;i<;i++)
{
Str1+=Sql.charAt(i)
}
return Str1
}
的回答,解决你的一系列问题。这种问题还是多试着从文档里边找找吧。