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

nl.vpro.hibernate.search6.InstantToEpochMillisBridge Maven / Gradle / Ivy

/*
 * Copyright (C) 2010 All rights reserved
 * VPRO The Netherlands
 */
package nl.vpro.hibernate.search6;

import org.hibernate.search.mapper.pojo.bridge.ValueBridge;
import org.hibernate.search.mapper.pojo.bridge.runtime.ValueBridgeFromIndexedValueContext;
import org.hibernate.search.mapper.pojo.bridge.runtime.ValueBridgeToIndexedValueContext;

import java.time.Instant;

public class InstantToEpochMillisBridge implements ValueBridge {

    @Override
	public Instant fromIndexedValue(Long value, ValueBridgeFromIndexedValueContext context) {
        return Instant.ofEpochMilli(value);
    }

    @Override
    public Long toIndexedValue(Instant instance, ValueBridgeToIndexedValueContext context) {
        return instance == null ? null : instance.toEpochMilli();
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy