Using LocalDateTime in Xtext Grammar [message #1843217] |
Tue, 20 July 2021 12:48 |
Dimg Cim Messages: 59 Registered: December 2015 |
Member |
|
|
Hello together,
can someone tell me how to use LocalDateTime in Xtext?
I defined this in xcore and convert it to Xtext dsl
class Event{
String ^id
String title
String summary
String location
String description
LocalDateTime start
LocalDateTime end
LocalDateTime created
LocalDateTime lastModified
String status
String source
}
type LocalDateTime wraps LocalDateTime
create{
LocalDateTime.parse(it, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
}convert{
if( it !== null ) DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(it)
}
The result looks likethis
[Event returns Event:
{Event}
'Event' '('
('start' start=LocalDateTime)?
('end' end=LocalDateTime)?
('title' title=EString)?
('location' location=EString)?
')';
EIntegerObject returns ecore::EIntegerObject:
'-'? INT;
LocalDateTime returns LocalDateTime:
'LocalDateTime' /* TODO: implement this rule and an appropriate IValueConverter */;
How can I fill my LocalDateTime as String in the dsl and after that convert it to LocalDateTime?
How should I use the IValueConverter?
Best regards
Dimg
[Updated on: Tue, 20 July 2021 12:49] Report message to a moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04293 seconds