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()的更多相关文章

  1. org.apache.commons.lang.StringUtils的常用方法

    org.apache.commons.lang.StringUtils是apache的commons-lang-x.x.jar下的包,里面包含很多字符串操作方法, 官网(http://commons. ...

  2. StringUtils中的常用的方法

    org.apache.commons.lang.StringUtils中常用的方法,这里主要列举String中没有,且比较有用的方法: 1. 检查字符串是否为空: static boolean isB ...

  3. org.apache.commons.lang.StringUtils中常用的方法

    org.apache.commons.lang.StringUtils中常用的方法,这里主要列举String中没有,且比较有用的方法: 1. 检查字符串是否为空: static boolean isB ...

  4. StringUtils 的常用方法

    StringUtils 方法的操作对象是 Java.lang.String 类型的对象,是 JDK 提供的 String 类型操作方法的补充,并且是 null 安全的(即如果输入参数 String 为 ...

  5. StringUtils类常用方法介绍

    StringUtils方法包的位置:org.apache.commons.lang.StringUtils StringUtils 方法的操作对象是 java.lang.String 类型的对象,是 ...

  6. 【转】 StringUtils中 isNotEmpty 和isNotBlank的区别

    [转自]http://blog.csdn.net/foamflower/article/details/5713604 isNotEmpty将空格也作为参数,isNotBlank则排除空格参数 Str ...

  7. StringUtils中 isNotEmpty 和isNotBlank的区别【java字符串判空】

    isNotEmpty(str)等价于 str != null && str.length > 0 isNotBlank(str) 等价于 str != null &&am ...

  8. StringUtils中 isEmpty 和isBlank的区别

    StringUtils方法的操作对象是java.lang.String类型的对象,是JDK提供的String类型操作方法的补充,并且是null安全的(即如果输入参数String为null则不会抛出Nu ...

  9. IT第九天 - 包、访问修饰符、变量的内存分配、String类中常用方法

    IT第九天 上午 包 1.包的命名规则:域名.项目名称.模块名 2.如:Wfei.com.windows.login 访问限制符 1.四种访问限制符分别对应为: (1)default:默认的,默认为p ...

随机推荐

  1. root无权限删除 原因 进程 占用 文件

    [root@test opt]# find / | grep gitlab | xargs rm -rfrm: cannot remove ‘/sys/fs/cgroup/devices/system ...

  2. git文章列表

    关于gitlab默认clone协议 Git实现从本地加入项目到远程仓库 翻翻git之---一个简单的标签控件 LabelView (随手发了两张小宝宝的玩耍照) id=1125" targe ...

  3. 代码空间项目 -- 获取当前时间之前的某一天-Calender类的使用

    Calendar类的静态方法getInstance()可以初始化一个日历对象:Calendar now = Calendar.getInstance(); 1.Calendar的基本用法calenda ...

  4. [coci2012]覆盖字符串 AC自动机

    给出一个长度为N的小写字母串,现在Mirko有M个若干长度为Li字符串.现在Mirko要用这M个字符串去覆盖给出的那个字符串的.覆盖时,必须保证:1.Mirko的字符串不能拆开,旋转:2.Mirko的 ...

  5. android4.3 蓝牙BLE编程

    一.蓝牙4.0简介 蓝牙4.0标准包含两个蓝牙标准,准确的说,是一个双模的标准,它包含传统蓝牙部分(也有称之为经典蓝牙Classic Bluetooth)和低功耗蓝牙部分(Bluetooth Low ...

  6. DHCP request error:Timed out waiting for dhcpcd to start【转】

    本文转载自:http://blog.csdn.net/zvivi521/article/details/9166899 [init.svc.dhcpcd_eth0]: [stopped] I/Serv ...

  7. Educational Codeforces Round 2 C. Make Palindrome —— 贪心 + 回文串

    题目链接:http://codeforces.com/contest/600/problem/C C. Make Palindrome time limit per test 2 seconds me ...

  8. ModuleNotFoundError: No module named 'numpy.core._multiarray_umath' ImportError: numpy.core.multiarray failed to import

      出现以下错误:可能是因为你的numpy版本太低 更新numpy的版本 pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgra ...

  9. zabbix数据库创建初始化

    MariaDB [(none)]> create database zabbix character set utf8; MariaDB [(none)]> grant all privi ...

  10. PICT实现组合测试用例

    成功安装后,在命令行中输入命令pict: 可以看到pict命令的一些选项: /o:N   组合数,默认值为2,即pict生成的测试用例集中每条测试数据会有两个值与其他测试集是不同的: /d:C   值 ...