All Projects → donbeave → Graphql Java Datetime

donbeave / Graphql Java Datetime

Licence: apache-2.0
GraphQL ISO Date is a set of RFC 3339 compliant date/time scalar types to be used with graphql-java.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Graphql Java Datetime

Dayjs
⏰ Day.js 2kB immutable date-time library alternative to Moment.js with the same modern API
Stars: ✭ 37,373 (+41892.13%)
Mutual labels:  time, date, datetime
Period
PHP's time range API
Stars: ✭ 616 (+592.13%)
Mutual labels:  time, date, datetime
React Datetime Picker
A datetime picker for your React app.
Stars: ✭ 294 (+230.34%)
Mutual labels:  time, date, datetime
dayjs
Extended fork of Day.js - 2KB immutable date library alternative to Moment.js
Stars: ✭ 36 (-59.55%)
Mutual labels:  time, datetime, date
Laydate
layDate(日期与时间组件) 是 layui 独立维护的三大组件之一
Stars: ✭ 1,066 (+1097.75%)
Mutual labels:  time, date, datetime
date-php
这是一个Javascript模仿PHP日期时间格式化函数,使用方法和PHP非常类似,有丰富的模板字符,并在原来的基础上增加了一些模板字符。 This is a date function that implement PHP in Javascript. It is very similar to PHP, has rich template characters, and enhances some template characters on the basis of the original.
Stars: ✭ 24 (-73.03%)
Mutual labels:  time, datetime, date
Tinydate
A tiny (349B) reusable date formatter. Extremely fast!
Stars: ✭ 990 (+1012.36%)
Mutual labels:  time, date, datetime
rescript-date
📆 Date manipulation in ReScript.
Stars: ✭ 101 (+13.48%)
Mutual labels:  time, datetime, date
When
A natural language date/time parser with pluggable rules
Stars: ✭ 1,113 (+1150.56%)
Mutual labels:  time, date, datetime
Carbon
A simple, semantic and developer-friendly golang package for datetime
Stars: ✭ 565 (+534.83%)
Mutual labels:  time, date, datetime
nepali-datetime
Python's core datetime inspired nepali datetime (BS date & NPT) package 🇳🇵
Stars: ✭ 36 (-59.55%)
Mutual labels:  time, datetime, date
Carbon
A simple PHP API extension for DateTime
Stars: ✭ 75 (-15.73%)
Mutual labels:  time, date, datetime
vue-timeselector
🕒 Simply customizable powerful time picker for Vue.js
Stars: ✭ 41 (-53.93%)
Mutual labels:  time, datetime, date
Vue Datetime
Mobile friendly datetime picker for Vue. Supports date and datetime modes, i18n and more.
Stars: ✭ 928 (+942.7%)
Mutual labels:  time, date, datetime
moment-cache
⏱ Simple utility to cache moment.js results and speed up moment calls.
Stars: ✭ 29 (-67.42%)
Mutual labels:  time, datetime, date
Pendulum
Python datetimes made easy
Stars: ✭ 4,639 (+5112.36%)
Mutual labels:  time, date, datetime
shamsi date
A Flutter and Dart package for using Jalali (Shamsi, Solar, Persian or Jalaali) calendar. You can convert, format and manipulate Jalali and Gregorian (Miladi) date and times.
Stars: ✭ 59 (-33.71%)
Mutual labels:  time, datetime, date
chronos
One library to rule the time
Stars: ✭ 17 (-80.9%)
Mutual labels:  time, datetime, date
Angular Moment Picker
Angular Moment Picker is an AngularJS directive for date and time picker using Moment.js.
Stars: ✭ 536 (+502.25%)
Mutual labels:  time, date, datetime
Zulu
A drop-in replacement for native Python datetimes that embraces UTC.
Stars: ✭ 52 (-41.57%)
Mutual labels:  time, date, datetime

graphql-java-datetime · License PRs Welcome

GraphQL ISO Date is a set of RFC 3339 compliant date/time scalar types to be used with graphql-java.

Build Status Latest Dev Build

Summary

A set of ISO 33601, RFC 3339 compatible date time scalars for GraphQL Java implementation (graphql-java) and GraphQL Java Kickstart (com.graphql-java-kickstart:graphql-spring-boot-starter).

Serialization

java.util.Date, java.time.LocalDate, java.time.LocalDateTime

Format JSON String
yyyy-MM-dd'T'HH:MM:ss.SSS'Z' 2017-07-09T13:14:45.947Z
yyyy-MM-dd'T'HH:MM:ss'Z' 2017-07-09T11:54:42Z
yyyy-MM-dd'T'HH:MM:ss 2017-07-09T11:54:42
yyyy-MM-dd 2017-07-09

java.time.LocalTime

Format JSON String
HH:MM:ss.SSS 17:59:59.129
HH:MM:ss 17:59:59
HH:MM 17:59

java.time.Duration

JSON String
PT1H30M
P1DT3H30M
P3Y6M4DT12H30M5S

Usage

Spring Boot

Add graphql-datetime-spring-boot-starter or graphql-datetime-spring-boot-starter-webflux starter (according to your spring boot stack) to your project first.

Installation

Maven

Add folowing to your pom.xml:

for Spring MVC:

<dependency>
  <groupId>com.zhokhov.graphql</groupId>
  <artifactId>graphql-datetime-spring-boot-starter</artifactId>
  <version>4.0.0</version>
</dependency>

or

for Spring WebFlux:

<dependency>
  <groupId>com.zhokhov.graphql</groupId>
  <artifactId>graphql-datetime-spring-boot-starter-webflux</artifactId>
  <version>4.0.0</version>
</dependency>

Gradle

Add folowing to your build.gradle:

for Spring MVC:

implementation("com.zhokhov.graphql:graphql-datetime-spring-boot-starter:4.0.0")

or

for Spring WebFlux:

implementation("com.zhokhov.graphql:graphql-datetime-spring-boot-starter-webflux:4.0.0")

Scalars

Add these scalars to your .graphqls schema file:

# java.util.Date implementation
scalar Date

# java.time.LocalDate implementation
scalar LocalDate

# java.time.LocalDateTime implementation
scalar LocalDateTime

# java.time.LocalTime implementation
scalar LocalTime

# java.time.OffsetDateTime implementation
scalar OffsetDateTime 

# java.time.YearMonth implementation
scalar YearMonth

# java.time.Duration implementation
scalar Duration

You can rename the scalar however you want with by simply adding the following properties to you application.yaml:

graphql:
  datetime:
    scalars:
      date:
        scalarName: MyDate
      localDate:
        scalarName: MyLocalDate
      localDateTime:
        scalarName: MyLocalDateTime
      localTime:
        scalarName: MyLocalTime
      offsetDateTime:
        scalarName: MyOffsetDateTime
      yearMonth:
        scalarName: MyYearMonth
      duration:
        scalarName: MyDuration

A custom format can be set for LocalDate and LocalDateTime only using the following properties in application.yaml

graphql:
  datetime:
    scalars:
      localDate:
        format: MM/dd/yyyy
      localDateTime:
        format: yyyy-MM-dd'T'HH:mm:ss

You can enable automatic zone conversion by adding the following property to your application.yaml. This will automatically convert between UTC and the default TimeZone for LocalDateTime:

graphql:
  datetime:
    scalars:
      zone-conversion-enabled: true

If using OffsetDateTime in order to present the offset and disable the automatic convertion to UTC from Jackson you should set to your application.yml the following:

spring:
  jackson:
    deserialization:
      adjust-dates-to-context-time-zone: false

Sample

Now you can use these scalars in your application. Here is graphql-datetime spring boot sample applications:

Bugs

To report any bug, please use the project Issues section on GitHub.

Contributing

Please contribute using Github Flow. Create a branch, add commits, and open a pull request.

License

Copyright © 2017-2021 Alexey Zhokhov. All rights reserved.

This project is licensed under the Apache License, Version 2.0 - see the LICENSE file for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].