Example: 2021-07-26T12:06:00.000+0400 -> 2021-07-26T08:06:00.000UTC
I know I can do it manually but I was wondering if there any libraries that already offer this feature
Example: 2021-07-26T12:06:00.000+0400 -> 2021-07-26T08:06:00.000UTC
I know I can do it manually but I was wondering if there any libraries that already offer this feature
No need to introduce a new third-party dependency here.
Simply use Java 8's ZonedDateTime
to perform exactly what you are looking for:-
// Define your date & date format.
String dateFormat = "dd-M-yyyy hh:mm:ss a";
String dateString = "26-7-2021 12:20:00 PM";
LocalDateTime localTime = LocalDateTime.parse(dateString, DateTimeFormatter.ofPattern(dateFormat));
// Convert between time zones
ZonedDateTime newYorkTime = localTime.atZone(ZoneId.of("America/New_York"));
ZonedDateTime londonTime = localTime.atZone(ZoneId.of("Europe/London"));
You can find the Java API documentation & some more detailed examples here.