java common.lang_Java 开源工具 Apache Common Lang

? ? ? ?Commons Lang 扩展了标准 java.lang api增加了串操作思路方法、基本数值思路方法、对象反射、创建和串行化以及 ?属性它还包含个可继承 enum 类型、对多种嵌套 Exception 类型支持、对java.util.Date 增强以及用于构建思路方法实用例如 hashCode、toString 和 equals我发现 Commons Lang对应用很多方面都很有帮助通过使用 Commons Lang您将编写更少代码从而可以更快地交付缺陷更少。但也有不足之处,这个问题可以解决,因为它是开源项目,发现不足之处,可以获取源码进行修正或者提交Bug。?

? ? ? ?官方网址:http://commons.apache.org/proper/commons-lang/

?

?

String manipulation (字符串操作)

? ? ? ? 一系列操作字符串的工具类,包括StringUtils, StringEscapeUtils, RandomStringUtils, Tokenizer, WordUtils,其中最常用的是StringUtils。

Character handing (字符管理)

? ? ? ? 主要处理char和Characters,包括CharSetUtils, CharSet, CharRange, CharUtils。其中CharSetUtils比较常用,其功能主要对字符串进行设置与操作。

JVM interaction (虚拟机交互)

? ? ? ? 虚拟机交互工具类有SystemUtils, CharEncoding。SystemUtils是个非常简单的工具类,通过这个工具类很方便获取到你所在的系统平台信息。

? ? ? ? CharEncoding与Java环境的字符集进行交互,能使用或者查看此环境中支持的字符集。

Serialization (序列化)

? ? ? ? 序列化工具类SerializationUtils, SerializationException。

Assorted Functions (其余功能)

? ? ? ? 其余功能的工具类ObjectUtils, ClassUtils, ArrayUtils, BooleanUtils

Flotsam (其他)

? ? ? ? 其他工具类BitField, Validate

lang3.time.*

? ? ? ? 时间管理工具类

? ? ? ? 1.?DateFormatUtils - 时间格式化工具类

? ? ? ? 2.?DateUtils - 时间工具类

? ? ? ? 3.?DurationFormatUtils - 用于计算时间间隔的工具类

? ? ? ? ? ? format常量如下:

29257C8B00E32819.jpg

? ? ? ? ? ? 下面是如何使用该工具类的例子:

? ? ? ? ? ??

class="java" name="code">Calendar calendar = Calendar.getInstance();

Date endDate = calendar.getTime();

calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) - 1);

Date startDate = calendar.getTime();

String startDateStr = DateFormatUtils.format(startDate,

"yyyy-MM-dd HH:mm:ss");

String endDateStr = DateFormatUtils.format(endDate,

"yyyy-MM-dd HH:mm:ss");

String durationByMonth = DurationFormatUtils.formatPeriod(

startDate.getTime(), endDate.getTime(), "M");

String durationByDay = DurationFormatUtils.formatPeriod(

startDate.getTime(), endDate.getTime(), "d");

System.out.println("start time : " + startDateStr);

System.out.println("end time : " + endDateStr);

System.out.println("时间间隔 (月): " + durationByMonth);

System.out.println("时间间隔 (日): " + durationByDay);

?

?

? ? ? ? 4.?FastDateFormat -?

Other

85789611CF3C8231.jpg

大小: 20.1 KB

查看图片附件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值