Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.arover:moment:1.8'
}
dependencies {
implementation("com.github.arover:moment:1.8")
}
<dependency>
<groupId>com.github.arover</groupId>
<artifactId>moment</artifactId>
<version>1.8</version>
</dependency>
libraryDependencies += "com.github.arover" % "moment" % "1.8"
:dependencies [[com.github.arover/moment "1.8"]]
Parse, validate, manipulate, and display dates in android. Inspired by momentjs.
Moment moment = new Moment() // create a moment with default calendar instance.
moment.toString() //"2016-08-29T08:02:17+08:00" (ISO 8601)
// Edit
// change moment time
moment.edit().minute(23).hour(14);
moment.fields().hour(); //=> 14
moment.fields().minute(); //=> 23
// Query
moment.query().isBefore(othermoment); // true or false
moment.query().lastMonday(); // the latest monday before this moment.
moment.query().firstDayOfMonth(); // the first day of month of this moment.
moment.query().isLeapYear();// false if current year is not leap year
// Field
// get some field
moment.fields().year(); // => 2016
moment.fields().month(); // => 7
moment.fields().day(); // => 29
// ....
// Edit
// manipulate moment,edit will change moment itself.
moment.edit().setMinute(23);
moment.edit().setHour(14);
moment.edit().minus(2, MomentUnit.DAY);
// Display
// show moment as string with default format.
moment.display().format();
// format as yyyy-MM-dd
moment.display().format("yyyy-MM-dd");
// Convert
// convert to normal java date classes.
moment.getCalendar();
moment.getDate();
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
//...
maven { url "https://jitpack.io" }
}
}
Step 2. Add the dependency
dependencies {
compile 'com.github.arover:moment:1.8'
}