A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/voidburn/cron-expression-descriptor below:

voidburn/cron-expression-descriptor: A Java library that converts cron expressions into human readable descriptions

Due to general lack of time, and limited interest, I am archiving this repository. No further versions will be updated on Maven. If you require customization you should include the cron and utils folders directly into your project.

Cron Expression Descriptor

A Java library that converts cron expressions into human readable descriptions. Adapted from original work by Brady Holt (https://github.com/bradymholt/cron-expression-descriptor)

Licensed under the MIT license

Add the following dependency to your pom.xml:

<dependency>
  <groupId>it.burning</groupId>
  <artifactId>cron-expression-descriptor</artifactId>
  <version>1.2.10</version>
</dependency>

Add the repositories and dependency to your gradle.build script:

repositories {
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}

dependencies {
    implementation "it.burning:cron-expression-descriptor:1.2.10"
}

A CronExpressionParser.Options object can be passed to CronExpressionDescriptor.getDescription(). The following options are available:

Example usage with default options:

CronExpressionDescriptor.getDescription("0 0 12 * * ?");
> "At 12:00, every day"

Example usage with custom options:

CronExpressionDescriptor.getDescription("0 0 12 * * ?",new Options(){{
       setLocale("it");
       setUse24HourTimeFormat(false);
       }});
       >"Alle 12:00 PM, ogni giorno"

Example usage for JEE Timer expressions [ Available Since Version 1.2.6+ ] (https://docs.oracle.com/javaee/7/tutorial/ejb-basicexamples004.htm):

CronExpressionDescriptor.getDescription("0 0 13 * * 0",new Options(){{
       setUseJavaEeScheduleExpression(true);
       }});
       >"At 13:00, only on Sunday"
CronExpressionDescriptor.getDescription("0 0 13 * * 7",new Options(){{
        setUseJavaEeScheduleExpression(true);
        }});
        >"At 13:00, only on Sunday"
CronExpressionDescriptor.getDescription("0 0 13 * * 1",new Options(){{
        setUseJavaEeScheduleExpression(true);
        }});
        >"At 13:00, only on Monday"

Please Note: Default options are cached internally, but if you want to use a custom Options set it is advisable to instantiate it only once and reuse it on every subsequent call to avoid useless allocation.

The following language translations are available.

If you want to manually set a default Locale for the descripion, to be used for all subsequent calls to " getDescription()" you can use the static method "setDefaultLocale()" by passing it the language identifier:

CronExpressionDescriptor.setDefaultLocale("it");
CronExpressionDescriptor.getDescription("0-10 11 * * *");
> "Alle 12:00, ogni giorno"

And you can revert at any time to the default Locale:

For Version 1.2.3+

CronExpressionDescriptor.setDefaultLocale();
CronExpressionDescriptor.getDescription("0-10 11 * * *");
 > "At 12:00, every day"

Up until Version 1.2.2

CronExpressionDescriptor.setDefaultLocale(null);
CronExpressionDescriptor.getDescription("0-10 11 * * *");
 > "At 12:00, every day"

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4