Online Java Compiler By
JavaTpoint.com
import java.sql.Timestamp; public class JavaTimestampGetNanosExample1 { public static void main(String[] args) { Timestamp ts1 = Timestamp.valueOf("2018-09-01 09:01:15"); System.out.println("Timestamp : "+ts1); //gets the Timestamp obejct's nanos value Integer val=ts1.getNanos(); System.out.println("Fractional seconds component : "+val); } }
Output