spreadme-test

a quikly development framework

License

License

GroupId

GroupId

club.spreadme
ArtifactId

ArtifactId

spreadme-test
Last Version

Last Version

1.4.8
Release Date

Release Date

Type

Type

jar
Description

Description

spreadme-test
a quikly development framework

Download spreadme-test

How to add to project

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

Dependencies

compile (4)

Group / Artifact Type Version
club.spreadme : spreadme-lang jar 1.4.8
club.spreadme : spreadme-database jar 1.4.8
mysql : mysql-connector-java jar 6.0.5
ch.qos.logback : logback-classic jar 1.2.3

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

spreadme commons

Apache Maven Java

Liense

This code is under the Apache Licence v2.

Install

  • Maven

  • Java8 +

  • Spread-commons

<dependency>
    <groupId>org.spreadme</groupId>
    <artifactId>spreadme-commons</artifactId>
    <version>1.5.2</version>
</dependency>

Example

  • Date Util
// 线程安全的时间解析工具
String formatter = "HH:mm:ss dd.MM.yyyy";
String text = "19:30:55 03.05.2015";
Date data = Dates.parse(text, formatter);
// Sun May 03 19:30:55 CST 2015

// 格式化日期
Dates.format(new Date(), formatter)
// 11:00:40 03.04.2020

// 其他用法
Console.info("今天开始时间: %s", Dates.getStartOfDate(new Date()));
Console.info("今天结束时间: %s", Dates.getEndOfDate(new Date()));
Console.info("100天前的时间: %s", Dates.getDate(new Date(), ChronoUnit.DAYS, -100));
Console.info("时间戳: %s", Dates.getTimestamp());
Date oldDate = Dates.parse("19:30:55 03.05.2015", formatter);
Duration duration = Dates.getDuration(new Date(), oldDate);
Console.info("相差天数: %d", duration.toDays());
  • IO Util
IOUtil.copy(InputStream, OutputStream);

RepeatableInputStream in = IOUtil.toRepeatable(InputStream inputStream);

IOUtil.zipFiles(List<File> files, OutputStream out);

IOUtil.zipResouces(final List<Resource> entries, OutputStream out)
...
  • 验证码工具 Captcha
CaptchaCode code = LineCaptcha.of(200, 50).create();

Apache

CaptchaCode code = CurvesCaptcha.of(200, 50).create();

Apache

  • Reflect 反射工具
private final String java_source_file = "CompilePerson.java";
private final String class_name = "org.spreadme.commons.test.CompilePerson";
try (FileInputStream in = new FileInputStream(java_source_file)) {
	final String content = StringUtil.fromInputStream(in);
	Reflect.compile(class_name, content).create("Tom", 27)
		.invoke("hello")
		.set("name", "Jack").set("age", 28)
		.fields()
		.forEach((key, value) -> Console.info("field name %s, value %s", key, value.get()));
}

//INFO[2020-04-04 19:17:23] My name is Tom, age is 27, randome string is RUEFkyHI
//INFO[2020-04-04 19:17:23] field name name, value Jack
//INFO[2020-04-04 19:17:23] field name age, value 28
  • Codec
//Hex
String plainText = StringUtil.randomString(10);
String hex = Hex.toHexString(plainText.getBytes(Charsets.UTF_8));
Hex.decode(hex);
//Base64
String base64 = Base64.toBase64String(plainText.getBytes(Charsets.UTF_8));
Base64.decode(base64);
  • Digest
FileInputStream in = new FileInputStream(testFile)
byte[] md5 = Digest.get(in, Algorithm.MD5);
byte[] sha256 = Digest.get(in, Algorithm.SHA256);

Versions

Version
1.4.8