team19hackathon2021 / issues-curriki

0 stars 0 forks source link

to create a new Java class LocalTimeSerializer do convert a LocalTime to a String. #35

Closed computate closed 2 years ago

computate commented 3 years ago

Mission to create a new Java class LocalTimeSerializer do convert a LocalTime to a String.

Mission

Your mission, should you choose to accept it, is to create a new Java class LocalTimeSerializer do convert a LocalTime 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.LocalTime;
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 LocalTimeSerializer extends JsonSerializer<LocalTime> {
}

Create the FORMATTimeDisplay field inside the LocalTimeSerializer class

    public static DateTimeFormatter FORMATTimeDisplay = DateTimeFormatter.ofPattern("h:mm a", Locale.US);

Create the serialize method inside the LocalTimeSerializer class

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

This message will not self-destruct.

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