All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dke.data.agrirouter.api.util.TimestampUtil.kt Maven / Gradle / Ivy

Go to download

This project contains the API for the communication with the agrirouter. Everything you need for the onboarding process, secure communication and much more.

There is a newer version: 1.0.0-jdk11-RC1
Show newest version
@file:JvmName("TimestampUtil")

package com.dke.data.agrirouter.api.util

import com.google.protobuf.Timestamp
import java.time.Instant

class TimestampUtil {

    /**
     * Will return a timestamp representation for the messaging.
     * @return -
     */
    fun current(): Timestamp {
        val timestampBuilder = Timestamp.newBuilder()
        timestampBuilder.seconds = Instant.now().epochSecond
        timestampBuilder.nanos = 1000000
        return timestampBuilder.build()
    }

    fun seconds(seconds: Long): Timestamp {
        if (seconds < 0) {
            throw IllegalArgumentException("Seconds [$seconds] should not be below 0.")
        }
        val timestampBuilder = Timestamp.newBuilder()
        timestampBuilder.seconds = seconds
        timestampBuilder.nanos = 1000000
        return timestampBuilder.build()
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy