WDate - Wrapper of Date


Source link: https://github.com/llollox/WDate-Wrapper-of-Date-Android

WDate - Wrapper of Date

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

Getting Started

Gradle

dependencies {

compile 'com.llollox.androidprojects:wdate:1.2.1' 
}

Maven

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

Getting Started

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);
  // Get the Date object Date date = wDate.getDate();

Configuration

// By default the week starts on Monday, // but it is possible to customize it // configuring the wdate object setting it // with WeekStart.SUNDAY wDate.setWeekStart(WeekStart weekStart);

Usage

Checkers
boolean isToday()  boolean isTomorrow()  boolean isYesterday()  // Week  boolean isMonday();
  boolean isThursday();
  boolean isWednesday();
  boolean isTuesday();
  boolean isFriday();
  boolean isSaturday();
  boolean isSunday();
  // Time  boolean isAtMidNight();
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
// Set the time to midnight 00:00:00.000 WDate atMidnight()
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 ()
Period
Date getFirstDayOfWeek ()  Date getLastDayOfWeek ()  Date getFirstDayOfMonth ()  Date getLastDayOfMonth ()  Date getFirstDayOfYear ()  Date getLastDayOfYear ()

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)
Static Methods

The following methods return a WDate object with the time set at midnight (00:00:00)

WDate.dayAfterTomorrow()  WDate.dayBeforeYesterday()  WDate.today()  WDate.tomorrow()  WDate.yesterday()  WDate.min(List<Date> dates)  WDate.max(List<Date> dates)

Resources

Android library to get device information in a super easy way.

A library to serialize and deserialize objects with minimum memory usage.

Bubble View for Android with custom stroke width and color, arrow size, position and direction.

Progress view that animates its state changes.

Open source Android Chat SDK / Messaging SDK that lets you add real time chat and in-app messaging in your mobile (android, iOS) applications and website.

A simple progress animation, inspired by the Uber app.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes