spreadme-lang

a quikly development framework

License

License

GroupId

GroupId

club.spreadme
ArtifactId

ArtifactId

spreadme-lang
Last Version

Last Version

1.4.8
Release Date

Release Date

Type

Type

jar
Description

Description

spreadme-lang
a quikly development framework

Download spreadme-lang

How to add to project

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

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

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