Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java get date in utc

OffsetDateTime now = OffsetDateTime.now(ZoneOffset.UTC);
System.out.println(now);
Comment

java get date in utc

private static Date getCurrentUtcTime() throws ParseException {
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MMM-dd HH:mm:ss");
    simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
    SimpleDateFormat localDateFormat = new SimpleDateFormat("yyyy-MMM-dd HH:mm:ss");
    return localDateFormat.parse( simpleDateFormat.format(new Date()) );
}
Comment

new date to utc string java


myJavaUtilDate.toInstant().toString()

  // output = "2020-05-05T19:46:12.912Z"
Comment

PREVIOUS NEXT
Code Example
Java :: try block in java 
Java :: java put a char array into a string 
Java :: java cast int to string 
Java :: prepared statement update 
Java :: string to string array java 
Java :: java string remove character 
Java :: what method is use for getting the index position of a character of a string in java 
Java :: java list distinct by object attribute 
Java :: reading from a text file in java 
Java :: arraylist of arraylist 
Java :: java create map 
Java :: sqlite java gradle 
Java :: android switch on change 
Java :: java add to map 
Java :: filter arraylist java 
Java :: setting scale to big decimal java 
Java :: how to convert char to uppercase java 
Java :: how to make java list 
Java :: does finally block executed after crash 
Java :: uninstall java ac 
Java :: java arraylist deep copy 
Java :: fill two dimensional array column by column java 
Java :: java convert date to localdate 
Java :: java mongodb find with multiple conditions 
Java :: change string to char array 
Java :: java iterator to stream 
Java :: threads array java 
Java :: java string length validation regex 
Java :: arraylist replace value java 
Java :: java repository sql find not in list 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =