30
Views
7
Comments
I need to convert DateTime to ZonedDateTime data type in Java.
Question
Application Type
Reactive
Service Studio Version
11.54.86 (Build 63808)

I have a field I need to save to that will later be consumed by a Java Backend.  I have a DateTime, but it needs to be configured and saved as a ZonedDateTime, which is NOT a supported Outsystems Datatype that I'm aware of.  Anyone have a good solution for this?

2024-09-12 02-43-38
Deepsagar Dubey

Hi @David McCulloch 

You can try to save ZonedDateTime  in a Text data type field, Then later when needed you can convert or format this in date time.

I hope it'll help you.

Thanks
Deep  

UserImage.jpg
David McCulloch

My problem is that I need to convert my Date Time to Zoned Date Time, and I'm very unsure of how to do this

2024-09-12 02-43-38
Deepsagar Dubey


Okay what i understood is that you consumed data from Java backend which has a specific ZoneDateTime and you want to conver it in another timezone (i.e. IST to US Timezone) then you can use Outssystems built in Date and Time functions (i.e. Addhours()) 

or if you want to change timezone according to client/browser location you can create a reusable client action which takes date (to convert) and detect device timezone and change timezone accordingly using JavaScript.

Reference Link 1

Reference Link 2

 also, you can try to use this component 

2025-09-25 14-38-22
Lokesh Kumar Yadav

OutSystems when you need to send it to a Java backend:

  1. OutSystems Frontend:

    • When the user selects a DateTime, convert it to ZonedDateTime in JavaScript, then save it as a string (ISO 8601 format) or timestamp (milliseconds).


  2. OutSystems Backend:

    • Store the formatted ZonedDateTime as Text or Long (timestamp).

  3. Java Backend:

    • On the backend, convert the received string or timestamp back into ZonedDateTime using Java's ZonedDateTime.parse():

      javaCopyEditString dateString = "2025-05-06T10:15:30+01:00";ZonedDateTime zonedDateTime = ZonedDateTime.parse(dateString);

This allows you to pass the ZonedDateTime across OutSystems and Java efficiently.

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi David,

As I understand it, a ZonedDateTime in Java is equal to a ISO date/time string with UTC and offset, and includes the name of the time zone, like "2024-12-03T10:15:30+01:00 Europe/Paris". OutSystems, when converting to JSON, already produces the "2024-12-03T10:15:30+01:00" part (for local time), but doesn't add the location. You could take a look at the Time Zone Forge Asset, that seems to be able to return that information (or, if you need it client-side, the TimeZoneReactiveUtils).

2023-03-24 11-55-45
Pawan Purohit

Hi,
In OutSystems, there is no built-in support for retrieving the IANA time zone name (like Europe/Paris ) — only the offset (e.g., +02:00) can be calculated using JavaScript on the client side. 
I'm sharing OML file hope that will help you.


Datezone.oap
2019-01-07 16-04-16
Siya
 
MVP

@David McCulloch : My suggestion is to have a wrapper function at the Java backend instead of doing the conversion at the OutSystems end. If your requirement is to maintain the user's time zone, then it has to be explicitly captured and stored in the database along with the UTC DateTime. In your wrapper function in Java, you can read both the UTC time and the user's time zone and convert them to a ZonedDateTime.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.