Results 1 to 3 of 3

Thread: MessageFormat

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2005
    Location
    Cebu
    Posts
    607

    Resolved MessageFormat

    I have this code
    Code:
    public class HelloWorld {
        
        public static void main(String[] args) {
            Object[] param = new Object[] {"some_value"};
            System.out.println(MessageFormat.format("select * from test where column1 = '{0}'", param));
        }
    
    }
    But it outputs

    select * from test where column1 = {0}

    and I need select * from test where column1 = 'some_value'

    Oh ok, I can get it to have
    Code:
            Object[] param = new Object[] {"'some_value'"};
            System.out.println(MessageFormat.format("select * from test where column1 = {0}", param));
    and outputs fine. But is there any way I can have the single quote on the .format's parameter? I mean, given by someone I can have some_value to be a final static String member, so I guess it would be better if single quote is on .format method parameter string.

    Thanks in advance!
    Last edited by nebulom; Mar 13th, 2006 at 04:18 AM.

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2005
    Location
    Cebu
    Posts
    607

    Re: MessageFormat

    Hmm. Nevermind (and thanks/sori for bothers).
    Within a String, "''" represents a single quote.
    http://java.sun.com/j2se/1.5.0/docs/...ageFormat.html

  3. #3
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: MessageFormat

    glad you could help you
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width