/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

import java.time.Instant ;
import java.time.temporal.ChronoUnit ;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{

Instant myInstant = Instant.now() ;
//Instant myInstant = Instant.now().truncatedTo( ChronoUnit.SECONDS ) ;

Instant myRoundedUpInstant = 
    Optional.of(myInstant)
        .filter( t -> t.getNano() != 0 )
        .map (t -> t.truncatedTo( ChronoUnit.SECONDS ).plusSeconds( 1 ) )
        .orElse( myInstant ) ;

System.out.println( "myInstant.toString(): " + myInstant ) ;
System.out.println( "myRoundedUpInstant(): " + myRoundedUpInstant ) ;

	}
}