StringUtils中常用方法leftPad(),rightPad(),center()
org.apache.commons.lang3的StringUtils
方法如下:
public static String leftPadTime(Integer time){
return StringUtils.leftPad(String.valueOf(time), 2, "0");
}
左侧填充:
leftPad():
StringUtils.leftPad(String str,int size);
StringUtils.leftPad(String str,int size,String padStr);
右侧填充:
rightPad():
StringUtils.rightPad(String str,int size);
StringUtils.rightPad(String str,int size,String padStr);
中间填充:
center():
StringUtils.center(String str, int size);
StringUtils.center(String str, int size, String padString);
例:
StringUtils.center("abcdef", 20);
返回结果(左右各7个空格):abcdef
StringUtils.center("abcdef", 20,"*_");
返回结果:*_*_*_abcdef*_*_*_*_
StringUtils.leftPad("abc", 10, "*");
返回结果:*******abc
StringUtils中常用方法leftPad(),rightPad(),center()的更多相关文章
- org.apache.commons.lang.StringUtils的常用方法
org.apache.commons.lang.StringUtils是apache的commons-lang-x.x.jar下的包,里面包含很多字符串操作方法, 官网(http://commons. ...
- StringUtils中的常用的方法
org.apache.commons.lang.StringUtils中常用的方法,这里主要列举String中没有,且比较有用的方法: 1. 检查字符串是否为空: static boolean isB ...
- org.apache.commons.lang.StringUtils中常用的方法
org.apache.commons.lang.StringUtils中常用的方法,这里主要列举String中没有,且比较有用的方法: 1. 检查字符串是否为空: static boolean isB ...
- StringUtils 的常用方法
StringUtils 方法的操作对象是 Java.lang.String 类型的对象,是 JDK 提供的 String 类型操作方法的补充,并且是 null 安全的(即如果输入参数 String 为 ...
- StringUtils类常用方法介绍
StringUtils方法包的位置:org.apache.commons.lang.StringUtils StringUtils 方法的操作对象是 java.lang.String 类型的对象,是 ...
- 【转】 StringUtils中 isNotEmpty 和isNotBlank的区别
[转自]http://blog.csdn.net/foamflower/article/details/5713604 isNotEmpty将空格也作为参数,isNotBlank则排除空格参数 Str ...
- StringUtils中 isNotEmpty 和isNotBlank的区别【java字符串判空】
isNotEmpty(str)等价于 str != null && str.length > 0 isNotBlank(str) 等价于 str != null &&am ...
- StringUtils中 isEmpty 和isBlank的区别
StringUtils方法的操作对象是java.lang.String类型的对象,是JDK提供的String类型操作方法的补充,并且是null安全的(即如果输入参数String为null则不会抛出Nu ...
- IT第九天 - 包、访问修饰符、变量的内存分配、String类中常用方法
IT第九天 上午 包 1.包的命名规则:域名.项目名称.模块名 2.如:Wfei.com.windows.login 访问限制符 1.四种访问限制符分别对应为: (1)default:默认的,默认为p ...
随机推荐
- SecureCRT中使用VBs脚本自动telnet登陆
查看SecureCRT帮助文档: Help-> Help Topics->Scripting -> Script Objects Reference -> Session Ob ...
- c# 获取当前行的位置信息
StackTrace st = new StackTrace(new StackFrame(true)); StackFrame sf = st.GetFrame(0); //文件位置 Console ...
- 在jboss中部署可执行jar, deploy executable jar in jboss
首先,题目是个伪命题, jboss容器是不支持直接部署可执行jar包的,jar只会被加载当作lib对待.这里提供了一个小的变通方案. 今天我遇到个问题,把我们的项目中的监控模块独立成一个小项目部署,监 ...
- android读取apk中已经存在的数据库信息
在android数据库编程方面,大家有没有遇到过,我要从指定位置的已经存在的数据库来进行操作的问题.之前我尝试了很多方法都没有成功,后来找到了解决的方法. 下面说明下这段代码的意思,第一步先判断在 ...
- BestCoder10 1001 Revenge of Fibonacci(hdu 5018) 解题报告
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5018 题目意思:给出在 new Fibonacci 中最先的两个数 A 和 B(也就是f[1] = A ...
- codeforces B. George and Round 解题报告
题目链接:http://codeforces.com/contest/387/problem/B 题目意思:给出1-n个问题,以及要满足是good rounde条件下这n个问题分别需要达到的compl ...
- Power Strings--KMP
https://cn.vjudge.net/problem/POJ-2406 上面是比赛链接. 题目意思很明确,问最多是多少个子串连接而成的? 这个需要用到KMP,很好的理解KMP的Next数组.Ne ...
- 「DP」区间dp
区间dp? 状态设计为描述一段区间的dp. eg:f[i][j]表示从 i 到 j 这个区间上的最优值.
- Azure Key Vault (1) 入门
<Windows Azure Platform 系列文章目录> 为什么要使用Azure Key Vault? 我们假设在微软云Azure上有1个场景,在Windows VM里面有1个.NE ...
- POJ2823(优先队列)
Sliding Window Time Limit: 12000MS Memory Limit: 65536K Total Submissions: 50738 Accepted: 14590 ...