Skip to content

Commit

Permalink
Java 8 Instant
Browse files Browse the repository at this point in the history
  • Loading branch information
MherBaghinyan committed Apr 16, 2019
1 parent 3ae6a12 commit bbe21ca
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.joda.time.Instant;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
Expand All @@ -12,18 +11,16 @@

public class ConvertDateTime {

public static void main(String[] args) throws ParseException {
public static void main(String[] args) {

java8();
joda();
Date date = simpleDateTimeFormatter();
Date date = coreDate();
calendar(date);
}

private static Date simpleDateTimeFormatter() throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("dd-M-yyyy hh:mm:ss");
String dateInString = "22-04-2019 10:20:56";
Date date = sdf.parse(dateInString);
private static Date coreDate() {
Date date = new Date();

System.out.println("Date - Time in milliseconds : " + date.getTime());

Expand All @@ -46,6 +43,8 @@ private static void joda() {
}

private static void java8() {
long instantMillis = java.time.Instant.now().toEpochMilli();

LocalDateTime localDateTime = LocalDateTime.now();
ZoneId id = ZoneId.systemDefault();
ZonedDateTime zdt = ZonedDateTime.of(localDateTime, id);
Expand Down

0 comments on commit bbe21ca

Please sign in to comment.