Java Timestamp Guide

Java code examples for Unix timestamps using java.time.Instant, System.currentTimeMillis(), and LocalDateTime conversions with timezone handling.

Built by Michael Lip

Frequently Asked Questions

How do I get the current timestamp in Java?

Use System.currentTimeMillis() for milliseconds, or Instant.now().getEpochSecond() for seconds. The java.time API (Java 8+) is preferred over the legacy Date class.

How do I convert an epoch to a date in Java?

Use Instant.ofEpochSecond(1712000000) for seconds or Instant.ofEpochMilli(1712000000000L) for milliseconds. Convert to LocalDateTime with LocalDateTime.ofInstant(instant, ZoneId.of("UTC")).

What is the difference between Instant and LocalDateTime?

Instant represents a point on the UTC timeline (like an epoch). LocalDateTime represents a date and time without timezone information. Use Instant for timestamps and LocalDateTime for display.

How do I format a date in Java?

Use DateTimeFormatter: LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")). The java.time formatters are thread-safe unlike the old SimpleDateFormat.

How It Works

This tool runs entirely in your browser using vanilla JavaScript. No data is sent to any server. All conversions and calculations happen locally on your device, ensuring complete privacy.

EpochPilot uses the browser's built-in Intl.DateTimeFormat API and the IANA timezone database provided by your operating system. This means timezone conversions are always accurate, including Daylight Saving Time transitions.

Related Tools

Privacy

Everything runs locally in your browser. No timestamps, dates, or personal data are transmitted to any server. The source code is open on GitHub.

Contact

EpochPilot is built and maintained by Michael Lip. For questions or feedback, email [email protected].

📊 Format data from our Timestamp Format Encyclopedia — 93 formats documented