Giter Site home page Giter Site logo

iandarwin / date4j Goto Github PK

View Code? Open in Web Editor NEW
13.0 5.0 10.0 70 KB

Code for date4j.net's simple date API, with a POM file, for upload to Maven Central.

Home Page: http://date4j.net/

License: Other

Shell 0.22% Java 99.78%
date-time date-formatting date-calculations java

date4j's Introduction

date4j

license BSD2 green badge

What?

This is Ian Darwin’s repackaging of Hirondelle Systems’s Date4J API.

Think of date4j as "the small, simple, sensible Date API for Java."

Another take: "One class to date them all". Literally, one class for almost everything.

Read all about it on https://github.com/johanley/date4j.

But do note that the problems that lead to the creation of date4j have been solved in all modern releases of Java! The Java 8 "new date/time API" (JSR-310, package java.time) has what you need; see https://docs.oracle.com/javase/tutorial/datetime/

Remember, today one might just as well use java.time.* instead.

Mavenizing Date4J

The code’s original author is not a fan of Maven, but he thoughtfully put it under the BSD license, and his web page links to my redistribution, this is my "Redistribution and use in source and binary forms" with an intent to make it available to all Maven/Gradle/Buildr/etc Nexus/MavenCentral users.

I originally said that: I have made no code changes, and plan to make none. However, that is no longer strictly true; since the original author has not updated his code in five years, I’ve taken it upon myself to add a module-info file, just declaring the package itself. There are no external dependencies, so that’s valid. This should help those wanting to use date4j with JPMS, JigSaw, the Java Modules System, whatever you call Java Modules.

I have however reorganized the code into standard Maven/Gradle directory structure, added the POM file, removed the lib directory’s only file JUnit.jar (replaced with a Maven depends), and set this up for inclusion in Maven Central and uploaded it (URL above).

date4j's People

Contributors

dependabot[bot] avatar iandarwin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

date4j's Issues

comparing 2 dates

I would like to point out an issue that might not be an issue after all but let me take you through my example..

i want to compare a date to another date without the hours , minutes ,seconds etc.

the one date is now without the hh mm ss

  //Now Date
        DateTime now = DateTime.now(TimeZone.getDefault()).getStartOfDay();

so the other date comes from a feed where the format is "YYYY-MM-DD"

so i create the date from this format
DateTime date_to_compare = new DateTime(date_strStartDate);

if the date_to_compare is the same day as today,

it doesn't equal the now date.

because date_to_compare has null values for hours, minutes,seconds etc.

so in the end this never returns true even though its the same date.

if (now .gteq(date_to_compare ) && now .lteq(date_to_compare )   ){
   return true;
}

in order for this to work i came down to this idea.
DateTime date_to_compare = new DateTime(date_strStartDate+" 00:00:00.0000");
i explicitely add hours minutes, seconds to the date string in order to give the constructor some values.
then the previous statement returns true finally.

but this got me headache for 4 days to understand. i am making this an issue so if you would like to address it as a solution to change the

default null values of the constructor to zeros 00:00:00.0000.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.