Code Monkey home page Code Monkey logo

simpledate's Introduction

Introduction Say Thanks! License

SimpleDate is a Kotlin Library which helps you format the date as per your requirement.

Star ⭐ this repo to show your support and it really does matter! 👏

Getting Started

In project-level build.gradle:

allprojects {
   repositories {
      ...
      maven { url 'https://jitpack.io' }
    }
}

In app-level build.gradle:

dependencies {
     implementation 'com.github.sidhuparas:SimpleDate:<latest-version>'
}

Version 2.0+ Backward Incompatible

SimpleDate uses Kotlin Extension Functions since Version 2.0. This makes it incompatible with the older versions of the library. But thanks to extension functions, the API looks very clean on Kotlin as well as Java.

Usage

You can use the methods on a date object. Following are the available functions:

For Date and Time

date                                 
     .toDateTimeStandard()               // 13 August 2019 21:55:11
     .toDateTimeStandardIn12Hours()      // 13 August 2019 9:55:11 PM
     .toDateTimeStandardInDigits()       // 13-08-2019 21:55:11
     .toDateTimeStandardInDigitsAnd12Hours()     // 13-08-2019 9:55:11 PM
     .toDateTimeStandardConcise()                // 13 Aug 2019 21:55:11
     .toDateTimeStandardConciseIn12Hours()       // 13 Aug 2019 9:55:11 PM
     .toDateTimeYY()                     // 13 August 19 21:55:11
     .toDateTimeYYIn12Hours()            // 13 August 19 9:55:11 PM
     .toDateTimeYYInDigits()             // 13-08-19 21:55:11
     .toDateTimeYYInDigitsAnd12Hours()   // 13-08-19 9:55:11 PM
     .toDateTimeYYConcise()              // 13 Aug 19 21:55:11
     .toDateTimeYYConciseIn12Hours()     // 13 Aug 19 9:55:11 PM
     .toZuluFormat()                     // 2019-08-19T21:16:55:11.926Z                   

For Time Only

date
     .toTimeStandard()                           // 21:55:11
     .toTimeStandardWithoutSeconds()             // 21:55
     .toTimeStandardIn12Hours()                  // 9:55:11 PM
     .toTimeStandardIn12HoursWithoutSeconds()    // 9:55 PM

For Date Only

date
      .toDateStandard()               // 13 August 2019
      .toDateStandardConcise()        // 13 Aug 2019
      .toDateStandardInDigits()       // 13-08-2019
      .toDateYY()                     // 13 August 19
      .toDateYYConcise()              // 13 Aug 19
      .toDateYYInDigits()             // 13-08-19
      .toDateYMD()                    // 2019 August 13
      .toDateYMDConcise()             // 2019 Aug 13
      .toDateYMDInDigits()            // 2019-08-13
      .toDateEMd()                    // Tue, Aug 13
      .toDateEMYShort()               // Tue, Aug 19
      .toDateEMY()                    // Tuesday, August 2019

For Day Only

date.toDay()                    // Tuesday

Examples

  • Kotlin:
   val date = Date()
   println(date.toDateTimeStandard())
  • Java:
    Date date = new Date();
    System.out.println(SimpleDateKt.toDateTimeStandard(date));

Contributions

  • Fork the repo
  • Create a new branch and make changes
  • Push the code to the branch and make a PR! 👍

Special Thanks

  • to Mahima for testing out the early version and helping in bug fix 👏
  • to Sahil for suggesting the use of Kotlin Extension Functions ❤️

simpledate's People

Contributors

sidhuparas avatar diegoalvis avatar llxzy avatar

Stargazers

 avatar Nguyễn Hoàng Ân avatar betül avatar Jessica Ernst avatar Wade avatar Benjamin Kadel avatar Piyush Johnson avatar Jimmy Horan avatar Nicolas Martinus Manurung avatar Saravanan Mani avatar Myo Thiha avatar VOLKAN AĞAOĞLU avatar typ Ahmed Sleem avatar Peter Fam avatar Nisarg avatar Pranav Lathigara avatar quentin avatar Dhruv Chandrani avatar Rygel Louv avatar Sanoj Punchihewa avatar  avatar Raza Abbas avatar Jignesh N Patel avatar Warm Man avatar Walter Juan avatar  avatar  avatar alphaDroid89 avatar ysf.cyln avatar Bogdan Roatis avatar Webserveis avatar David Ruiz avatar Bakyt Itigulov avatar Dzhunet Hasan avatar Abed avatar narakai avatar Vinamra Sareen avatar Jowan avatar Abhishek Kumar avatar Saurabh Sandav avatar Sahil Kumar avatar Bhargav Pandya avatar Mahima avatar

Watchers

typ Ahmed Sleem avatar

simpledate's Issues

Add More Date/Time Formats

SimpleDate can convert the date object into 23 different formats. There can be more combinations possible. Think and implement them.

Apart from it, any kind of extra good-to-have Android library features will be welcomed.

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.