how to convert unix epoch microseconds into Java time stampHow do I efficiently iterate over each entry in a Java Map?How do I call one constructor from another in Java?How do I read / convert an InputStream into a String in Java?How do I generate random integers within a specific range in Java?How do I determine whether an array contains a particular value in Java?How do I declare and initialize an array in Java?How to get the current time in YYYY-MM-DD HH:MI:Sec.Millisecond format in Java?How to split a string in JavaHow do I convert a String to an int in Java?How can I create a Java 8 LocalDate from a long Epoch time in Milliseconds?
Why does the U.S. tolerate foreign influence from Saudi Arabia and Israel on its domestic policies while not tolerating that from China or Russia?
If your plane is out-of-control, why does military training instruct releasing the joystick to neutralize controls?
How do you create draggable points inside a graphic image?
Was the Ford Model T black because of the speed black paint dries?
Parse source code of the RAPID robot-automation language
SOLVED - GFCI - should my neutral and ground have continuity?
Are unclear "take-it or leave-it" contracts interpreted in my favor?
What was the definition of "set" that resulted in Russell's Paradox
Does throwing a penny at a train stop the train?
Drawing color tiles using Tikz
Shortest distance around a pyramid?
Why was hardware diversification an asset for the IBM PC ecosystem?
Why won't this charge pump supply more than a couple of milliamps?
Are randomly-generated passwords starting with "a" less secure?
Why isn't there research to build a standard lunar, or Martian mobility platform?
Why isn't pressure filtration popular compared to vacuum filtration?
During copyediting, journal disagrees about spelling of paper's main topic
will it increase or decrease my credit score, if i split a high balance on 2 credit cards
Why does Hellboy file down his horns?
Why are they 'nude photos'?
Leave PhD after one year or finish it to the end?
How were Martello towers supposed to work?
Is Arc Length always irrational between two rational points?
What is this welding tool I found in my attic?
how to convert unix epoch microseconds into Java time stamp
How do I efficiently iterate over each entry in a Java Map?How do I call one constructor from another in Java?How do I read / convert an InputStream into a String in Java?How do I generate random integers within a specific range in Java?How do I determine whether an array contains a particular value in Java?How do I declare and initialize an array in Java?How to get the current time in YYYY-MM-DD HH:MI:Sec.Millisecond format in Java?How to split a string in JavaHow do I convert a String to an int in Java?How can I create a Java 8 LocalDate from a long Epoch time in Milliseconds?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Epoch time in MicroSeconds : 1529948813696000
how to convert this into java time stamp.
I am able to convert epoch time in MilliSeconds using this method
Instant instant = Instant.ofEpochMilli(Long.parseLong("1529957592000"));
Date parsedDate = dateFormat.parse(instant.atZone(ZoneId.of("America/Chicago")).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS")).toString())
Need help to convert Epoch time in Microseconds ?
java unix
add a comment |
Epoch time in MicroSeconds : 1529948813696000
how to convert this into java time stamp.
I am able to convert epoch time in MilliSeconds using this method
Instant instant = Instant.ofEpochMilli(Long.parseLong("1529957592000"));
Date parsedDate = dateFormat.parse(instant.atZone(ZoneId.of("America/Chicago")).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS")).toString())
Need help to convert Epoch time in Microseconds ?
java unix
add a comment |
Epoch time in MicroSeconds : 1529948813696000
how to convert this into java time stamp.
I am able to convert epoch time in MilliSeconds using this method
Instant instant = Instant.ofEpochMilli(Long.parseLong("1529957592000"));
Date parsedDate = dateFormat.parse(instant.atZone(ZoneId.of("America/Chicago")).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS")).toString())
Need help to convert Epoch time in Microseconds ?
java unix
Epoch time in MicroSeconds : 1529948813696000
how to convert this into java time stamp.
I am able to convert epoch time in MilliSeconds using this method
Instant instant = Instant.ofEpochMilli(Long.parseLong("1529957592000"));
Date parsedDate = dateFormat.parse(instant.atZone(ZoneId.of("America/Chicago")).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS")).toString())
Need help to convert Epoch time in Microseconds ?
java unix
java unix
edited 9 hours ago


Basil Bourque
127k36 gold badges427 silver badges599 bronze badges
127k36 gold badges427 silver badges599 bronze badges
asked 9 hours ago
RameshRamesh
514 bronze badges
514 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
While the Instant
class doesn't have an ofEpochNano(long)
method, it does has an overload of ofEpochSecond(long, long)
that accepts a nanosecond offset along with the epoch seconds.
With a little math you can just convert your epoch microseconds to seconds plus an offset and create your Instant
using it, like so:
long epochMicroSeconds = 1_529_948_813_696_123L;
long epochSeconds = epochMicroSeconds / 1_000_000L;
long nanoOffset = ( epochMicroSeconds % 1_000_000L ) * 1_000L ;
Instant instant = Instant.ofEpochSecond( epochSeconds, nanoOffset ) ;
See this code run live at IdeOne.com.
instant.toString(): 2018-06-25T17:46:53.696123Z
That's better! You just escaped my downvote.
– Dawood ibn Kareem
9 hours ago
Yah, I was spacing between millis and micros for a bit, needed to update the math. I should know better than to post code without running it through a debugger first... :p
– azurefrog
9 hours ago
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f56997280%2fhow-to-convert-unix-epoch-microseconds-into-java-time-stamp%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
While the Instant
class doesn't have an ofEpochNano(long)
method, it does has an overload of ofEpochSecond(long, long)
that accepts a nanosecond offset along with the epoch seconds.
With a little math you can just convert your epoch microseconds to seconds plus an offset and create your Instant
using it, like so:
long epochMicroSeconds = 1_529_948_813_696_123L;
long epochSeconds = epochMicroSeconds / 1_000_000L;
long nanoOffset = ( epochMicroSeconds % 1_000_000L ) * 1_000L ;
Instant instant = Instant.ofEpochSecond( epochSeconds, nanoOffset ) ;
See this code run live at IdeOne.com.
instant.toString(): 2018-06-25T17:46:53.696123Z
That's better! You just escaped my downvote.
– Dawood ibn Kareem
9 hours ago
Yah, I was spacing between millis and micros for a bit, needed to update the math. I should know better than to post code without running it through a debugger first... :p
– azurefrog
9 hours ago
add a comment |
While the Instant
class doesn't have an ofEpochNano(long)
method, it does has an overload of ofEpochSecond(long, long)
that accepts a nanosecond offset along with the epoch seconds.
With a little math you can just convert your epoch microseconds to seconds plus an offset and create your Instant
using it, like so:
long epochMicroSeconds = 1_529_948_813_696_123L;
long epochSeconds = epochMicroSeconds / 1_000_000L;
long nanoOffset = ( epochMicroSeconds % 1_000_000L ) * 1_000L ;
Instant instant = Instant.ofEpochSecond( epochSeconds, nanoOffset ) ;
See this code run live at IdeOne.com.
instant.toString(): 2018-06-25T17:46:53.696123Z
That's better! You just escaped my downvote.
– Dawood ibn Kareem
9 hours ago
Yah, I was spacing between millis and micros for a bit, needed to update the math. I should know better than to post code without running it through a debugger first... :p
– azurefrog
9 hours ago
add a comment |
While the Instant
class doesn't have an ofEpochNano(long)
method, it does has an overload of ofEpochSecond(long, long)
that accepts a nanosecond offset along with the epoch seconds.
With a little math you can just convert your epoch microseconds to seconds plus an offset and create your Instant
using it, like so:
long epochMicroSeconds = 1_529_948_813_696_123L;
long epochSeconds = epochMicroSeconds / 1_000_000L;
long nanoOffset = ( epochMicroSeconds % 1_000_000L ) * 1_000L ;
Instant instant = Instant.ofEpochSecond( epochSeconds, nanoOffset ) ;
See this code run live at IdeOne.com.
instant.toString(): 2018-06-25T17:46:53.696123Z
While the Instant
class doesn't have an ofEpochNano(long)
method, it does has an overload of ofEpochSecond(long, long)
that accepts a nanosecond offset along with the epoch seconds.
With a little math you can just convert your epoch microseconds to seconds plus an offset and create your Instant
using it, like so:
long epochMicroSeconds = 1_529_948_813_696_123L;
long epochSeconds = epochMicroSeconds / 1_000_000L;
long nanoOffset = ( epochMicroSeconds % 1_000_000L ) * 1_000L ;
Instant instant = Instant.ofEpochSecond( epochSeconds, nanoOffset ) ;
See this code run live at IdeOne.com.
instant.toString(): 2018-06-25T17:46:53.696123Z
edited 9 hours ago


Basil Bourque
127k36 gold badges427 silver badges599 bronze badges
127k36 gold badges427 silver badges599 bronze badges
answered 9 hours ago
azurefrogazurefrog
8,4027 gold badges31 silver badges50 bronze badges
8,4027 gold badges31 silver badges50 bronze badges
That's better! You just escaped my downvote.
– Dawood ibn Kareem
9 hours ago
Yah, I was spacing between millis and micros for a bit, needed to update the math. I should know better than to post code without running it through a debugger first... :p
– azurefrog
9 hours ago
add a comment |
That's better! You just escaped my downvote.
– Dawood ibn Kareem
9 hours ago
Yah, I was spacing between millis and micros for a bit, needed to update the math. I should know better than to post code without running it through a debugger first... :p
– azurefrog
9 hours ago
That's better! You just escaped my downvote.
– Dawood ibn Kareem
9 hours ago
That's better! You just escaped my downvote.
– Dawood ibn Kareem
9 hours ago
Yah, I was spacing between millis and micros for a bit, needed to update the math. I should know better than to post code without running it through a debugger first... :p
– azurefrog
9 hours ago
Yah, I was spacing between millis and micros for a bit, needed to update the math. I should know better than to post code without running it through a debugger first... :p
– azurefrog
9 hours ago
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f56997280%2fhow-to-convert-unix-epoch-microseconds-into-java-time-stamp%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown