Skip to content

Improve JulianDateTime #14

Answered by cusher
igr asked this question in General
Dec 12, 2022 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

I came up a slightly obnoxious test case for precision. Quick calculation to start off with:

1 JD = 86400s
0.00000000001 JD = 864ns
0.00000000578 JD = 499392ns = 0.499392ms
0.00000000579 JD = 500256ns = 0.500256ms

So in theory if we add/subtract 0.00000000578 from any JulianDate that is a whole number of millis, it should not round away, while if we add/subtract 0.00000000579 it should round away.

And so:

	@Test
	void bigDecimalToLocalDateTimeDelta() {
		JulianDate jdt = new JulianDate(BigDecimal.valueOf(2457754.4));
		LocalDateTime ldt = LocalDateTime.of(2016, 12, 31, 21, 36, 0, 0);

		assertEquals(ldt, jdt.toLocalDateTime());
		assertEquals(ldt, jdt.sub(0.00000000578).toLocalDateTime(…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@igr
Comment options

igr Dec 18, 2022
Maintainer Author

@cusher
Comment options

@igr
Comment options

igr Dec 19, 2022
Maintainer Author

Answer selected by igr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
2 participants