Results 1 to 3 of 3

Thread: MessageFormat

Threaded View

  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.

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