Helma logo
helma.org » Home > docs > reference > Packages Object

Packages Object

Scripting Java, accessing Java classes and working with Java Objects within Helma's Javascript environment.

Objects from the core Java API (in the java.* packages) can be instantiated directly, while other Java classes need the Packages prefix.

Syntax
var buffer = new java.lang.StringBuffer()
var foo = new Packages.com.bar.util.Foo()

Take a look at Sun's Java API documentation to find out more about Java objects.

Example
/**
* This function returns a date string
* from a Date object formatted
* according to a custom locale.
*/
function getLocaleDate(date) {
   // Here the locale is set (english / Ireland):
   var locale = new java.util.Locale("en", "IE");
   // Creating the date formatter:
   var dateFormat = new java.text.SimpleDateFormat("EEEE d MMMM yyyy, HH:mm", locale);
   // Formatting the Date object as date string:
   var dateString = dateFormat.format(date);
   return(dateString);
}


Please also refer to the Scripting Java documentation.


Up: Reference
Previous: Global Object Next: Application Object

... comment


Page last modified on 2005-11-29 10:55 by czv