您的位置:首页 > 数据库 > Oracle

java实现oracle函数rpad和lpad

2017-07-20 10:43 246 查看
import junit.framework.TestCase;

public class StringTest extends TestCase{
public void ntestRpad(){
System.out.println(rpad("1",3,"0"));
}
public void testLpad(){
System.out.println(lpad("1",3,"0"));
}
private String lpad(String s, int n, String replace) {
while (s.length() < n) {
s = replace+s;
}
return s;
}
private String rpad(String s, int n, String replace) {
while (s.length() < n) {
s = s+replace;
}
return s;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: