_bulli Posted April 19, 2013 Report Posted April 19, 2013 i am getting Phone number from data base as (1111111111), but i need something like (111-111-1111)....help me , how to get that...in form.setfield property("phone number" , xxxxxx) Thank you
vikuba Posted April 19, 2013 Report Posted April 19, 2013 [url="http://stackoverflow.com/questions/5114762/how-do-format-a-phone-number-as-a-string-in-java"]http://stackoverflow.com/questions/5114762/how-do-format-a-phone-number-as-a-string-in-java[/url] [url="http://stackoverflow.com/questions/7730006/java-format-a-string-as-a-telephone-number"]http://stackoverflow.com/questions/7730006/java-format-a-string-as-a-telephone-number[/url]
katthi Posted April 19, 2013 Report Posted April 19, 2013 [left][b][size=2][color=#7f0055][size=2][color=#7f0055]import[/color][/size][/color][/size][/b][size=2][color=#000000] java.text.DecimalFormat;[/color][/size][/left] [left][b][size=2][color=#7f0055][size=2][color=#7f0055]public[/color][/size][/color][/size][/b][size=2][color=#000000] [/color][/size][b][size=2][color=#7f0055][size=2][color=#7f0055]class[/color][/size][/color][/size][/b][size=2][color=#000000] c {[/color][/size][/left] [left][b][size=2][color=#7f0055][size=2][color=#7f0055]public[/color][/size][/color][/size][/b] [b][size=2][color=#7f0055][size=2][color=#7f0055]static[/color][/size][/color][/size][/b] [b][size=2][color=#7f0055][size=2][color=#7f0055]void[/color][/size][/color][/size][/b][size=2] main(String args[]){[/size][/left] [left][b][size=2][color=#7f0055][size=2][color=#7f0055]long[/color][/size][/color][/size][/b][size=2] phone = 1234567890L;[/size][/left] [left][size=2]DecimalFormat decimalFormat = [/size][b][size=2][color=#7f0055][size=2][color=#7f0055]new[/color][/size][/color][/size][/b][size=2] DecimalFormat([/size][size=2][color=#2a00ff][size=2][color=#2a00ff]"0000000000"[/color][/size][/color][/size][size=2]);[/size][/left] [left][size=2]String pString= decimalFormat.format(phone);[/size][/left] [left][size=2]java.text.MessageFormat [u]format[/u]=[/size][b][size=2][color=#7f0055][size=2][color=#7f0055]new[/color][/size][/color][/size][/b][size=2] java.text.MessageFormat([/size][size=2][color=#2a00ff][size=2][color=#2a00ff]"({0})-{1}-{2}"[/color][/size][/color][/size][size=2]);[/size][/left] [left][size=2]String[] pArr={pString.substring(0, 3),[/size][/left] [left][size=2]pString.substring(3,6),[/size][/left] [left][size=2]pString.substring(6)};[/size][/left] [left][size=2]System.[/size][i][size=2][color=#0000c0][size=2][color=#0000c0]out[/color][/size][/color][/size][/i][size=2].println(decimalFormat.format(pArr));[/size][/left] [left][size=2]}[/size][/left] [size=2]}[/size]
ZuniorVentiyar Posted April 19, 2013 Report Posted April 19, 2013 wow so many quick answers .....@thread starter .... hope u got u r answer ......
vijayjust4u Posted April 19, 2013 Report Posted April 19, 2013 Regular expression + String Tokenizer....
_bulli Posted April 19, 2013 Author Report Posted April 19, 2013 [quote name='buddi_ramarao' timestamp='1366399726' post='1303635206'] wow so many quick answers .....@thread starter .... hope u got u r answer ...... [/quote] trying....
Recommended Posts