How to convert first latter to capital using String Template in java

137 views
Skip to first unread message

chauhan....@gmail.com

unread,
Sep 21, 2015, 3:52:55 AM9/21/15
to stringtemplate-discussion
Dear ,
I am using String template in java and i am not able to find any method that can convert first latter of String in capital. Example- i have double so using String template i want to convert it into Double. I am not able to find any suitable method to achieve the same.Please guide me.

Thanking You.

Jim Idle

unread,
Sep 22, 2015, 1:48:05 AM9/22/15
to stringtempla...@googlegroups.com
You are not really supposed to modify the data in a template, but do this before you send it to the template. You can add a renderer for strings though and do nothing with a null format and some action witha a non-null format.





--
You received this message because you are subscribed to the Google Groups "stringtemplate-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stringtemplate-dis...@googlegroups.com.
To post to this group, send email to stringtempla...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/stringtemplate-discussion/0f922807-5c7a-417e-ae08-326a5bda7601%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Saurabh Chauhan

unread,
Sep 22, 2015, 2:23:55 AM9/22/15
to stringtempla...@googlegroups.com
Can you please explain with example ?

My code is shown below:
$CS.allStructFields:{field |
$field.name$=obj.get$field.type;format="capital"$("$field.name$");
}$


Using above format="capital" method i am not able to convert first letter to capital.  I also tried through format="uppercase".

let me know if you are not clear with my question.

Thank You



--
You received this message because you are subscribed to a topic in the Google Groups "stringtemplate-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stringtemplate-discussion/7DjZJ5bKr6M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stringtemplate-dis...@googlegroups.com.

To post to this group, send email to stringtempla...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
With Regards,
Saurabh

Jim Idle

unread,
Sep 22, 2015, 3:43:46 AM9/22/15
to stringtempla...@googlegroups.com
Just follow the example - you have to write and implement the renderer. As in the example.

Jim

Rupert Smith

unread,
Oct 1, 2015, 10:45:58 AM10/1/15
to stringtemplate-discussion, chauhan....@gmail.com
I wrote some custom string renders to support various forms of camel case and so on. You can find them here, and use that as a starting point for writing your own: 

Reply all
Reply to author
Forward
0 new messages