team19hackathon2021 / issues-curriki

0 stars 0 forks source link

to create a new Java class ZonedDateTimeSerializer do convert a ZonedDateTime to a String. #33

Closed computate closed 2 years ago

computate commented 3 years ago

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

Mission

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

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 java.util.Locale;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

/**
 **/

public class ZonedDateTimeSerializer extends JsonSerializer<ZonedDateTime> {
}

Create the ZONED_DATE_TIME_FORMAT field inside the ZonedDateTimeSerializer 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 ZonedDateTimeSerializer class

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

Create the serialize method inside the ZonedDateTimeSerializer class

    public void serialize(ZonedDateTime o, JsonGenerator generator, SerializerProvider provider) {
        generator.writeString(o.format(ZONED_DATE_TIME_FORMATTER));
    }

This message will not self-destruct.

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