Giter VIP home page Giter VIP logo

dateformatter's Introduction

DateFormatter

Simple ISO 8601 date formatting library for ClientVault products. Formatted as yyyy-mm-dd'T'hh:MM:ssZZZZ. May not be usefult for other applications

Usage

Basic Usage

String dateTime = "1904-01-01T00:00:00+00:00"

Date date = DateFormatter.from(dateTime).toDate();

String date = DateFormatter.from(dateTime).to(FULL_MONTH); // 1 January 1904
...

Date Comparison

Compare two dates. Can compare ISO 8601 date string's (or any DateFormatter string output) to a java.Date object or another string.

String dateTime = "1904-01-01T00:00:00+00:00"
Date date = new Date();

DateFormatter.isDatePastOrFuture(dateTime, date);
// returns +1 if date 1 is in the future of date 2
// return -1 if date 1 is the the past of date 2
// returns 0 if dates are exactly the same
// returns -2 otherwise

Check if a date is withi a range from today.

Calendar pastCalendar = Calendar.getInstance();
pastCalendar.set(DAY_OF_MONTH, -3);

DateFormatter.isWithinDayRange(pastCalendar.getTime(), -7);
// return true. pastCalendar is within the past 7 days.

DateFormatter.Type Enum

Use the Type enum to format a date or string

FULL_MONTH("dd MMMM yyyy"),
FULL_MONTH_TIME_12("dd MMMM yyyy' - 'h:mm aa"),
FULL_MONTH_TIME_24("dd MMMM yyyy' - 'HH:mm"),
SHORT_MONTH("dd MMM yyyy"),
SHORT_MONTH_TIME_12("dd MMM yyyy' - 'h:mm aa"),
SHORT_MONTH_TIME_24("dd MMM yyyy' - 'HH:mm"),
TIME_12("h:mm aa"),
TIME_24("HH:mm"),
NO_YEAR_SHORT("dd MMM"),
NO_YEAR_FULL("dd MMMM"),
NO_DAY("MMMM yyyy"),
NO_DAY_SHORT("MMM yy"),
MONTH_ONLY_SHORT("MMM"),
MONTH_ONLY_FULL("MMMM"),
DAY_ONLY("d"),
NO_DAY_SHORT_MONTH("MMM yyyy"),
NO_DAY_SHORT_YEAR("MMMM yy"),

SERVER("yyyy-MM-dd'T'HH:mm:ss"),
SERVER_TIMEZONE("yyyy-MM-dd'T'HH:mm:ssZZZZZ"),
SERVER_NO_TIME("yyyy-MM-dd");

dateformatter's People

Contributors

willconno avatar

Watchers

James Cloos 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.