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

berlin.yuna.survey.logic.CommonUtils Maven / Gradle / Ivy

Go to download

Survey is a plain java library to provide a base for surveys / questionnaires. It also provides a function to generate diagrams and to measure answer times.

There is a newer version: 0.1.110
Show newest version
package berlin.yuna.survey.logic;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Optional;

import static java.time.LocalDateTime.now;

public class CommonUtils {

    private CommonUtils() {
    }

    public static boolean hasText(final Object string) {
        return toText(string).isPresent();
    }

    public static Optional toText(final Object string) {
        return string instanceof String && ((String) string).trim().length() > 0 ? Optional.of((String) string) : Optional.empty();
    }

    public static LocalDateTime getTime() {
        return now(ZoneId.of("UTC"));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy