Hi Jagdish,
The line of code where you are getting the error starts with a Dot(.) which is illegal, remove the dot and then try running the mapping.
Best method would be to write the code first in NWDS and then use it in UDF.
For your requirement, you can fix this only by doing a Java Mapping or writing an UDF as mentioned by Inaki.
Regards,
Nitin Deshpande