Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] generating current date/time
[Acceleo] generating current date/time [message #718173] Tue, 23 August 2011 13:47 Go to next message
Wilbert Alberts is currently offline Wilbert Alberts
Messages: 94
Registered: June 2010
Member
Hi,

I want to generate a 'comment' line like: "Generated by Acceleo at [today/time]"

But how do i get the date and time of the moment of invocation?

Greetings,
Wilbert.
Re: [Acceleo] generating current date/time [message #718491 is a reply to message #718173] Wed, 24 August 2011 13:54 Go to previous messageGo to next message
Norman  is currently offline Norman
Messages: 17
Registered: June 2011
Junior Member
Hi Wilbert,
well i can help you. I think Acceleo has no function to do this, u need an external JavaFunction.

Like this

public String getDate()
	{
		String actual;
		DateFormat dateFormatter = DateFormat.getDateTimeInstance();
		dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+2"));
		actual=dateFormatter.format(new Date());
		return actual;
	}


you have to update the Timezone, for mine its GMT+2.

You can call up the function in Acceleo with a query:

[query public getDate(empty : String) : String = invoke('JavaFunctions', 'getDate()',Sequence{})/]


first invoke parameter is path from project to your java data, where you defined the function, the second is the Name of the Function.

In generation you have to call [getDate('')/]. This sould write the current Date/Time.

Greetings,
Norman
Re: [Acceleo] generating current date/time [message #718701 is a reply to message #718491] Thu, 25 August 2011 05:47 Go to previous messageGo to next message
Wilbert Alberts is currently offline Wilbert Alberts
Messages: 94
Registered: June 2010
Member
Hi Norman,

Thank you. This completely answers my question!

Greetings,
Wilbert.
Re: [Acceleo] generating current date/time [message #719140 is a reply to message #718701] Fri, 26 August 2011 07:33 Go to previous message
Stephane Begaudeau is currently offline Stephane Begaudeau
Messages: 406
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

I would complete this perfect answer with a working example of the declaration of the Java service, its wrapper and a call of the wrapper.

If you need more information about Java services in Acceleo, you can have a look at the video included in the documentation.

Regards,

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau
Google+: stephane.begaudeau
Blog: http://stephanebegaudeau.tumblr.com
Acceleo Documentation: http://docs.obeonetwork.com/acceleo



Previous Topic:[Acceleo] how to format generated java code?
Next Topic:[Acceleo 3]Decision outgoing are switching
Goto Forum:
  


Current Time: Sat Sep 20 18:11:51 GMT 2014

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

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