Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » how to insert datetime in target file's name in EGX
how to insert datetime in target file's name in EGX [message #1849455] Thu, 20 January 2022 14:32 Go to next message
fang yan is currently offline fang yanFriend
Messages: 27
Registered: October 2020
Junior Member
Hi,

I am trying to generate files using EGL/EGX.
I'd like the datetime to be included in the file names every time I run the transformation.
I used the following codes, but it didn't work.
Could anyone help me fix this?

pre{
 var javaDate = new Native("java.util.Date");
 var javaDateString = new String;
 javaDateString= javaDate.toString();
}
rule AC2Diagram {
  template : "GSN_AC_R1.egl"
  target : "GSN_AC_R1_"+javaDateString+".dot"
}


Thanks
Fang
Re: how to insert datetime in target file's name in EGX [message #1849456 is a reply to message #1849455] Thu, 20 January 2022 14:36 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

Hi Fang,

Could you please explain what you mean by "it didn't work"? Are you getting a runtime exception, is the date just not in the format you'd like, something else?

Best,
Dimitris
Re: how to insert datetime in target file's name in EGX [message #1849460 is a reply to message #1849456] Thu, 20 January 2022 15:13 Go to previous messageGo to next message
fang yan is currently offline fang yanFriend
Messages: 27
Registered: October 2020
Junior Member
Hi Dimitris,

I just found out that I got an exception because the format is illegal as shown in the image attached.

How could I change the format to remove all the spaces, etc.?

Thanks
Fang
Re: how to insert datetime in target file's name in EGX [message #1849461 is a reply to message #1849460] Thu, 20 January 2022 15:17 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

Hi Fang,

The following should do the trick.

new Native("java.text.SimpleDateFormat")("dd-MM-yyyy").
  format(new Native("java.util.Date")).println();


Best,
Dimitris
Re: how to insert datetime in target file's name in EGX [message #1849468 is a reply to message #1849461] Thu, 20 January 2022 20:11 Go to previous message
fang yan is currently offline fang yanFriend
Messages: 27
Registered: October 2020
Junior Member
Great thanks, Dimitris.
Previous Topic:Unexpected modification of the input model
Next Topic:epsilon.emf.loadRegisteredMetamodel has no effect in Antrunner
Goto Forum:
  


Current Time: Sat Apr 27 06:49:58 GMT 2024

Powered by FUDForum. Page generated in 0.04277 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top