Code Monkey home page Code Monkey logo

dateconvert's Introduction

Build Status CircleCI Coverage Status

DateConvert

Simple Java library to convert common Date/Time objects. Use old style Date or Calendar and convert it to new Java 7+ Date/Time objects or visa versa.

Take a java.time.LocalDate object, add time and zone and convert it to java.util.Date with an one-liner.

Usage

Use DateConvert to convert Calendar, Instant, ZonedDateTime and even LocalDate.

For example:

// java.util.Date to Calendar with default zone
DateConvert.from(date).toCalendarWithDefaultZone();

// Calendar to java.time.ZonedDateTime
DateConvert.from(calendar).toZonedDateTime();

// java.time.LocalDate -> java.util.Date with time 12:30 and default zone
DateConvert.from(localDate).withLocalTime(12, 30, 0, 0).withDefaultZoneId().toDate();

Converts from/to

  • Calendar
  • Date
  • Instant
  • LocalDate
  • LocalDateTime
  • Millis
  • Timestamp
  • ZonedDateTime

Quickstart

  1. Add JitPack repository to your build file, see here
  2. Add the DateConvert dependency

For maven the pom.xml looks like

...
<repositories>
	<repository>
		<id>jitpack.io</id>
		<url>https://jitpack.io</url>
	</repository>
</repositories>
...
<dependencies>
	<dependency>
		<groupId>com.github.javablick</groupId>
		<artifactId>dateconvert</artifactId>
		<version>2.0.0</version>
	</dependency>
</dependencies>
  1. Use the DateConvert class, e.g. DateConvert.from(date).toCalendar();

Questions? Need help?

Write me an email.

See also my homepage.

dateconvert's People

Contributors

javablick avatar

Stargazers

 avatar  avatar  avatar

dateconvert's Issues

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.