Coder Social home page Coder Social logo

faisalazam / daysdifferencecalculator Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 218 KB

Command line application to calculate the difference (in days) between provided date strings.

Home Page: http://faisalazam.github.io/DaysDifferenceCalculator/

Java 100.00%
java maven pom cli-app command-line hamcrest-matchers junit-jupiter-api maven-jar-plugin maven-surefire-plugin reflection

daysdifferencecalculator's Introduction

DaysDifferenceCalculator

Date Calculator: Problem Description

Command line application (built using JAVA 20) for calculating the number of full days elapsed between start and end dates.

The first and last days are considered partial days and are never counted.

Following this logic, an experiment that has run from 1972-11-07 to 1972-11-08 should return 0, because there are no fully elapsed days contained in between those dates.

And 2000-01-01 to 2000-01-03 should return 1.

The solution needs to cater to all valid dates between 1901-01-01 and 2999-12-31.

This is a command line based system with at least one way of providing input and output on the terminal.

No libraries should be used to build this solution.

Although any dates specified within the valid date range listed above should work, here are a few test cases to validate the output of your program.

TEST CASES

1. 1983-06-02 – 1983-06-22: 19 days
2. 1984-07-04 – 1984-12-25: 173 days
3. 1989-01-03 – 1983-08-03: 1979 days

Steps to test:

  1. Java 20 and maven should be installed on the system
  2. Download the project code
  3. Navigate to the project folder/directory
  4. Package/generate the jar file by executing mvn clean package command from terminal
  5. Then execute java -jar target/DaysDifferenceCalculator-1.0-SNAPSHOT.jar command from terminal to see it in action :)
  6. In order to use this code with some IDE,
    • mvn idea:idea command can be executed for Intellij,
    • mvn eclipse:eclpise command can be executed for Eclipse.

Running tests from IDE

I guess, since Java 17, we need to add the following to VM options in order to use reflection.

pom.xml has already been updated accordingly, but don't forget to add the following to VM options if the runner class is using reflection and you are running the runner class/test from IDE:

--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED

Application's Demo

demo.png

daysdifferencecalculator's People

Contributors

faisalazam avatar

Watchers

 avatar  avatar

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.