townmc-utils

townmc-utils is project which contains common utils ,string, http request!

License

License

GroupId

GroupId

com.townmc
ArtifactId

ArtifactId

townmc-utils
Last Version

Last Version

3.6.1
Release Date

Release Date

Type

Type

jar
Description

Description

townmc-utils
townmc-utils is project which contains common utils ,string, http request!
Project URL

Project URL

https://github.com/fatalwing/utils
Source Code Management

Source Code Management

https://github.com/fatalwing/utils

Download townmc-utils

How to add to project

<!-- https://jarcasting.com/artifacts/com.townmc/townmc-utils/ -->
<dependency>
    <groupId>com.townmc</groupId>
    <artifactId>townmc-utils</artifactId>
    <version>3.6.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.townmc/townmc-utils/
implementation 'com.townmc:townmc-utils:3.6.1'
// https://jarcasting.com/artifacts/com.townmc/townmc-utils/
implementation ("com.townmc:townmc-utils:3.6.1")
'com.townmc:townmc-utils:jar:3.6.1'
<dependency org="com.townmc" name="townmc-utils" rev="3.6.1">
  <artifact name="townmc-utils" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.townmc', module='townmc-utils', version='3.6.1')
)
libraryDependencies += "com.townmc" % "townmc-utils" % "3.6.1"
[com.townmc/townmc-utils "3.6.1"]

Dependencies

compile (10)

Group / Artifact Type Version
commons-net : commons-net jar 2.0
org.apache.httpcomponents : httpclient jar 4.5.3
org.apache.httpcomponents : httpmime jar 4.5.3
commons-logging : commons-logging jar 1.2
org.apache.poi : poi jar 3.16
org.apache.poi : poi-ooxml jar 3.16
org.apache.poi : poi-scratchpad jar 3.16
org.apache.poi : poi-excelant jar 3.16
dom4j : dom4j jar 1.6.1
com.auth0 : java-jwt jar 3.12.1

test (1)

Group / Artifact Type Version
junit : junit jar 4.13.1

Project Modules

There are no modules declared in this project.

通用帮助类

说明

经常用到的对象、日期、数字、字符串、线程、json、xml、excel、http请求帮助类。

日期

DateUtil

/**
 * 时间精确到年月日时分秒
 */
public final static String FULL_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
/**
 * 时间精确到年月日
 */
public final static String DATE_PATTERN = "yyyy-MM-dd";
/**
 * 时间精确到年月日小时
 */
public final static String DATE_HOUR_PATTERN = "yyyy-MM-dd HH";
/**
 * 时间精确到年月日小时
 */
public final static String DATE_MINUTE_PATTERN = "yyyy-MM-dd HH:mm";
/**
 * 时间精确到年月日,没有分隔符
 */
public final static String NOT_SEPARATOR_DATE_PATTERN = "yyyyMMdd";

/**
 * 获得UTC时间
 * @return Date
 */
public static Date utcDate();

/**
 * 将当前时间转换成字符串
 *
 * @return String 转换后的时间字符串
 */
public static String dateToString();

/**
 * 将当前时间转换成指定格式的字符串
 *
 * @param pattern
 *            String 指定格式
 * @return String 转换后的时间字符串
 */
public static String dateToString(String pattern);

/**
 * 将时间转换成规定格式的字符串
 *
 * @param pattern
 *            String 格式
 * @param date
 *            Date 需要转换的时间
 * @return String 转换后的时间字符串
 */
public static String dateToString(String pattern, Date date);

/**
 * 将时间转换成规定格式的字符串
 *
 * @param pattern
 *            String 格式
 * @param date
 *            Date 需要转换的时间
 * @Param zone
 *            TimeZone 时区
 * @return String 转换后的时间字符串
 */
public static String dateToString(String pattern, Date date, TimeZone zone);

/**
 * 比较两日期是否相等
 *
 * @param pattern
 *            String 格式
 * @param sFirstDate
 *            String 比较的第一个日期字符串
 * @param sSecondlyDate
 *            String 比较的第二个日期字符串
 * @return boolean true 第一个日期在第二个日期之前; false 第一个日期和第二个日期相等或之后
 */
public static boolean compareDate(String pattern, String sFirstDate, String sSecondlyDate);

/**
 * 格式化日期
 *
 * @param pattern
 *            String 格式
 * @param sDate
 *            String 日期字符串
 * @return Date 格式化后的日期
 */
public static Date formatDate(String pattern, String sDate);

/**
 * 功能:滚动日期
 *
 * @param date
 *            Date 需要滚动的日期
 * @param field
 *            int 需要滚动的字段(参照Calendar的字段)
 * @param step
 *            int 步长 正数时是增加时间,而负数时是减少时间
 * @return Date 滚动后的日期
 */
public static Date rollDate(Date date, int field, int step);

/**
 * 设置时间
 *
 * @param date
 *            Date 设置的时间
 * @param field
 *            int 设置的字段(参照Calendar的字段)
 * @param value
 *            int 时间
 * @return Date 设置后的时间
 */
public static Date setDate(Date date, int field, int value);

/**
 * 获得时间中的字段的值
 *
 * @param field
 *            int 时间字段(参照Calendar的字段)
 * @return int 时间字段值
 */
public static int getField(int field);

/**
 * 两个时间的差距。目前支持秒、分钟、小时、天、月、年
 * 两个时间参数不分前后。效果一样。
 * @param one 第一个时间
 * @param two 第二个时间
 * @param precision 精度 与Calendar中的常量定义对应 13表示秒 12表示分钟 11表示小时 6表示天 2表示月 1表示年
 * @return long
 */
public static long difference(Date one, Date two, int precision);

字符串

StringUtil

 

Versions

Version
3.6.1
3.5.1
3.4