Skip to content

Commit

Permalink
Minor statistics improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
colorizenl committed Oct 3, 2023
1 parent a565000 commit d24a070
Show file tree
Hide file tree
Showing 34 changed files with 1,128 additions and 1,025 deletions.
14 changes: 1 addition & 13 deletions _development/outline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "com.github.ben-manes.versions" version "0.47.0"
id "com.github.ben-manes.versions" version "0.48.0"
}

apply plugin: "java-library"
Expand All @@ -8,7 +8,7 @@ apply plugin: "maven-publish"
apply plugin: "signing"

group = "nl.colorize"
version = "2023.12"
version = "2023.15"
sourceCompatibility = "17"
targetCompatibility = "17"
compileJava.options.encoding = "UTF-8"
Expand All @@ -21,8 +21,8 @@ repositories {
}

dependencies {
api "com.google.guava:guava:32.1.1-jre"
testImplementation "org.junit.jupiter:junit-jupiter:5.9.3"
api "com.google.guava:guava:32.1.2-jre"
testImplementation "org.junit.jupiter:junit-jupiter:5.10.0"
}

java {
Expand Down
7 changes: 4 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ Colorize Java Commons
=====================

Set of Java libraries for web, desktop, and mobile applications. It is used in all Java-based
applications and libraries developed by [Colorize](http://www.colorize.nl/en/).
applications and libraries developed by [Colorize](http://www.colorize.nl), where it has been
in use since 2007.

The library focuses on portability, and supports a wide variety of platforms and environments.
It can be used in back-end applications, in cloud environments, in desktop applications on
Expand All @@ -24,13 +25,13 @@ to the dependencies section in `pom.xml`:
<dependency>
<groupId>nl.colorize</groupId>
<artifactId>colorize-java-commons</artifactId>
<version>2023.12</version>
<version>2023.15</version>
</dependency>

The library can also be used in Gradle projects:

dependencies {
implementation "nl.colorize:colorize-java-commons:2023.12"
implementation "nl.colorize:colorize-java-commons:2023.15"
}

Documentation
Expand Down
22 changes: 13 additions & 9 deletions source/nl/colorize/util/DateParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,18 @@
*/
public final class DateParser {

private static final TupleList<Pattern, String> PATTERNS = new TupleList<Pattern, String>()
.append(Pattern.compile("\\d{8}"), "yyyyMMdd")
.append(Pattern.compile("\\d{4}-\\d{2}-\\d{2}"), "yyyy-MM-dd")
.append(Pattern.compile("\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}"), "yyyy-MM-dd HH:mm")
.append(Pattern.compile("\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}"), "yyyy-MM-dd HH:mm:ss")
.append(Pattern.compile("\\d{2}-\\d{2}-\\d{4}"), "dd-MM-yyyy")
.append(Pattern.compile("\\d{2}-\\d{2}-\\d{4} \\d{2}:\\d{2}"), "dd-MM-yyyy HH:mm:ss")
.append(Pattern.compile("\\d{2}-\\d{2}-\\d{4} \\d{2}:\\d{2}:\\d{2}"), "dd-MM-yyyy HH:mm:ss")
.append(Pattern.compile("\\d{2}/\\d{2}/\\d{4}"), "MM/dd/yyyy")
private static final TupleList<Pattern, String> PATTERNS = new TupleList<String, String>()
.append("\\d{8}", "yyyyMMdd")
.append("\\d{4}-\\d{2}-\\d{2}", "yyyy-MM-dd")
.append("\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}", "yyyy-MM-dd HH:mm")
.append("\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}", "yyyy-MM-dd'T'HH:mm")
.append("\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}", "yyyy-MM-dd HH:mm:ss")
.append("\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}", "yyyy-MM-dd'T'HH:mm:ss")
.append("\\d{2}-\\d{2}-\\d{4}", "dd-MM-yyyy")
.append("\\d{2}-\\d{2}-\\d{4} \\d{2}:\\d{2}", "dd-MM-yyyy HH:mm:ss")
.append("\\d{2}-\\d{2}-\\d{4} \\d{2}:\\d{2}:\\d{2}", "dd-MM-yyyy HH:mm:ss")
.append("\\d{2}/\\d{2}/\\d{4}", "MM/dd/yyyy")
.map(Pattern::compile, format -> format)
.immutable();

private static final Map<ChronoUnit, Integer> CALENDAR_FIELD_MAPPING = Map.of(
Expand Down Expand Up @@ -147,6 +150,7 @@ private static SimpleDateFormat create(String dateFormat) {
* date that is before the original.
* <p>
* This method supports the following time units:
*
* <ul>
* <li>{@link ChronoUnit#SECONDS}</li>
* <li>{@link ChronoUnit#MINUTES}</li>
Expand Down
6 changes: 6 additions & 0 deletions source/nl/colorize/util/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.nio.file.StandardCopyOption;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.function.Function;
Expand Down Expand Up @@ -242,9 +243,14 @@ private static List<File> getDirectoryContents(File dir) {
* with only files matching the filter being returned.
*/
public static List<File> walkFiles(File dir, Predicate<File> filter) throws IOException {
if (!dir.isDirectory() && filter.test(dir)) {
return Collections.singletonList(dir);
}

return Files.walk(dir.toPath())
.map(Path::toFile)
.filter(file -> !file.isDirectory() && filter.test(file))
.sorted(Comparator.comparing(File::getAbsolutePath))
.toList();
}

Expand Down
1 change: 0 additions & 1 deletion source/nl/colorize/util/Platform.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public enum Platform {
.put("10.13", "High Sierra")
.put("10.14", "Mojave")
.put("10.15", "Catalina")
.put("10.16", "Big Sur") // Big Sur is both 10.16 and 11.0
.put("11.", "Big Sur")
.put("12.", "Monterey")
.put("13.", "Ventura")
Expand Down
Loading

0 comments on commit d24a070

Please sign in to comment.