team19hackathon2021 / issues-curriki

0 stars 0 forks source link

to create a new Java class ZonedDateTimeDeserializer do convert a String to a ZonedDateTime. #36

Closed computate closed 2 years ago

computate commented 3 years ago

Mission to create a new Java class ZonedDateTimeDeserializer do convert a String to a ZonedDateTime.

Mission

Your mission, should you choose to accept it, is to create a new Java class ZonedDateTimeDeserializer do convert a String to a ZonedDateTime. .

The day of the operation is October 26th, 2021

You will have 4 hours to complete your mission.

One of the project’s major goals is to establish https://cc.curriki.org as the global authoring and distribution hub and library for openly licensed, next generation, open educational resources (OER+) under the least restrictive Creative Commons license, CC-BY.

You will be joining a team of the boldest

of all Red Hatters for this mission, who will be at your service developing the code and automating the deployment to OpenShift.

How to get started:

Follow the instructions here to setup the project: https://github.com/team19hackathon2021/ActiveLearningStudio-API/tree/master/src

The details of your mission:

package org.curriki.api.enus.java;

import java.io.IOException;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;

/**
 **/

public class ZonedDateTimeDeserializer extends JsonDeserializer<ZonedDateTime> {
}

Create the ZONED_DATE_TIME_FORMAT field inside the ZonedDateTimeDeserializer class

    public static final String ZONED_DATE_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'['VV']'";

Create the ZONED_DATE_TIME_FORMATTER field inside the ZonedDateTimeDeserializer class

    public static final DateTimeFormatter ZONED_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern(ZONED_DATE_TIME_FORMAT);

Create the deserialize method inside the ZonedDateTimeDeserializer class

    public ZonedDateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) {

        return ZonedDateTime.parse(jsonParser.getText(), DateTimeFormatter.ofPattern(ZONED_DATE_TIME_FORMAT, deserializationContext.getLocale()).withZone(deserializationContext.getTimeZone().toZoneId()));
    }

This message will not self-destruct.

This message will not self destruct, because this project is open source.