Java Utililty Methods Instant Create

List of utility methods to do Instant Create

Description

The list of methods to do Instant Create are organized into topic(s).

Method

InstantconvertDotNetTicksToInstant(long dotNetTicks)
convert Dot Net Ticks To Instant
long ticksFromEpoch = dotNetTicks - EPOCHINDOTNETTICKS;
long millisecondsFromEpoch = ticksFromEpoch / 10000;
long fractionTicks = ticksFromEpoch % 10000;
return Instant.ofEpochMilli(millisecondsFromEpoch).plusNanos(fractionTicks * 100);
InstantdeserializeToInstant(String date)
deserialize To Instant
return Instant.parse(date);
InstantdeserializeToInstant(String date)
deserialize To Instant
return deserialize(date).toInstant(ZoneOffset.UTC);
Durationend(String msg, long amount, Instant start)
end
Duration d = Duration.between(start, Instant.now());
System.out.println("PerformanceTest: " + msg);
System.out.println("Total time needed: " + d.toMillis() / 1000d + " seconds for " + amount + " iterations");
System.out.println("That's " + d.toNanos() / (double) amount + "nanos per iteration");
return d;
InstantgetEarliestInstant()
get Earliest Instant
return earliestInstant;
InstantgetInstant(final Calendar calendar)
Get an instant from a calendar
return calendar.toInstant();
InstantgetInstant(LocalDate localDate)
get Instant
return localDate.atStartOfDay().atZone(DEFAULT_ZONE_ID).toInstant();
InstantgetInstantOfEpoch(long seconds)
gibt ein Instant zum Zeitstempel zurueck
return Instant.ofEpochSecond(seconds, 0);
InstantgetThisMonthBeginInstant()
get This Month Begin Instant
LocalDateTime localDate = LocalDateTime.now().withSecond(0).withHour(0).withMinute(0)
        .with(TemporalAdjusters.firstDayOfMonth()).truncatedTo(ChronoUnit.SECONDS);
return localDate.toInstant(ZoneOffset.UTC);
Instantinstant(int _y, int _m, int _d, int _H, int _M, int _S)
Get an Instant from local parameters: year, month, day, hour, minutes, seconds
return LocalDateTime.of(_y, _m, _d, _H, _M, _S).toInstant(localZoneOffset);