Giter Site home page Giter Site logo

naseemakhtar994 / wdate-wrapper-of-date-android Goto Github PK

View Code? Open in Web Editor NEW

This project forked from llollox/wdate-wrapper-of-date-android

0.0 1.0 0.0 18 KB

This is a utility class that wraps the Date class of Java providing some useful methods.

Java 100.00%

wdate-wrapper-of-date-android's Introduction

WDate - Wrapper of Date

This is an utility class that wraps the standard Date class providing some useful methods without using the Calendar object.

Alt text Android Arsenal

Getting Started

Gradle

dependencies {
  compile 'com.llollox.androidprojects:wdate:1.0.3'
}

Maven

<dependency>
  <groupId>com.llollox.androidprojects</groupId>
  <artifactId>wdate</artifactId>
  <version>1.0.3</version>
  <type>pom</type>
</dependency>

Usage

The first thing to do is set the date for our WDate object. This can be done in the following manner:

// Set its date as now
WDate wdate = new WDate();

// Set as its date the one passed as argument
WDate wdate = new WDate(yourDate);

// Set as its date the one passed as argument
wDate.setDate(yourDate);
Checkers
boolean isToday()

boolean isTomorrow()

boolean isYesterday()
Comparators
// Returns the number of days (absolute value) between the dates.
// The wdate's date is included, the other one not.
int getNumDaysBetween(Date date)

// Returns the number of months (absolute value) between the dates.
// The wdate's date is included, the other one not.
int getNumMonthsBetween(Date date)

// Returns the number of years (absolute value) between the dates.
// The wdate's date is included, the other one not.
int getNumYearsBetween(Date date)

// Returns the number of milliseconds (absolute value) between the dates.
long getMilliSecondsDifference(Date date)

// Checks if the wdate's date is contained in the period.
// Both start and end date limits are excluded.
boolean isInRange (Date start, Date end)

// Checks if both dates have same day, month and year.
boolean isSameDay(Date date)
Converters
// Returns the date setting its time to 00:00:00.000
Date getWithoutTime()
Formatter
// Format string following the Simple Date Format pattern.
String format (String sdfPattern)

Getters

Date
int getDay () // Day number in the month

int getMonth () // Months start from 0

int getYear ()

Time

int getHours () // 24h format

int getMinutes ()

int getSeconds ()

int getMilliSeconds ()

Modifiers

All modifiers supports method chaining.

Date
WDate addDays (int numDays)

WDate addMonths (int numMonths)

WDate addYears (int numYears)

Time

WDate addHours (int numHours)

WDate addMinutes (int numMinutes)

WDate addSeconds (int numSeconds)

WDate addMilliSeconds (int numMilliSeconds)

Setters

All setters supports method chaining.

Date
WDate setDay (int days)

WDate setMonth (int months)

WDate setYear (int years)

Time

WDate setHours (int hours)

WDate setMinutes (int minutes)

WDate setSeconds (int seconds)

WDate setMilliSeconds (int milliSeconds)

wdate-wrapper-of-date-android's People

Contributors

llollox avatar

Watchers

Naseem Akhtar 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.