Java.text.MessageFormat -- How to pre-pend  '0'

Hi,
I need to create a 10 digit number and I'm using MessageFormat.
My numbers range from
008-4146075
to
008-4146107.
So essentially, only the last 3 digits need to be changed.
HOWEVER, I'm having trouble trying to figure out how to pre-pend the '0' when less than 100.
I have a loop that goes through these statements:
           String result;
           Object[] values = new Object[1];
           values[0] = new Long(075);  //"075" is my initial number
           result = MessageFormat.format("{0,date,'008-4146'###}", values);
           System.out.println(result);// "008-4146*75*" is printed out
when I actually want "008-4146*075*"
Thanks in advance. Any help would be appreciated!

EvoBevo wrote:
OK--- I'm dumb.
Sorry!
I just need to put everthing else besides the initial "008-".
So it would be '008-'#######....
But thanks DrLaszloJamf!But what if instead of 4146075 for your number, you have 0146075? Then you'd have the same problem.
Just try 0 instead of #, will ya?

Similar Messages

  • Java.util.Formatter vs. java.text.MessageFormat

    Hi,
    Which formatter is faster java.text.MessageFormat or java.util.Formatter?
    At the moment I format all my strings with java.text.MessageFormat, however I want to speed-up the formatting of the strings that I log, so I though of using java.util.Formatter instead.
    Is there a benchmark that compares between those formatters?

    hanoch_y wrote:
    Why do you day those 2 doesn't do the same thing? They format messages using parameters the user passes.A 747 and a dump truck both do the same thing: move people and cargo from one place to another. But people have been known to express strong preferences for one or the other, depending on their circumstances. They usually have pretty good reasons for their choices.
    No I didn't used a profiler. It just an hunch.Never trust hunches, especially when it comes to performance questions. You'll end up making a fool of yourself every time.

  • Please help with java.text.MessageFormat...

    Hi all
    I'm reasonably new to java and have been struggling with this one for a while. I wonder if anyone can help?
    The following code...
    Object[] testArgs = {new Long(1273), "MyDisk"};
    MessageFormat form = new MessageFormat(
    "The disk \"{1}\" contains {0} file(s).");
    System.out.println(form.format(testArgs));
    ...gives the following output...
    The disk "MyDisk" contains 1,273 file(s).
    I simply want to get rid of the comma, so that the output becomes...
    The disk "MyDisk" contains 1273 file(s).
    Any ideas? Many thanks for reading my thread and for any help you may be able to offer!
    Kind Regards
    Jon

    contains {0,number,#} file(s).

  • Printing in java - text positioning

    Hi there, I need some pointers in the right direction please.
    I need to print a page out to fill in a pre-printed sheet. The data to go onto the sheet is purely numbers, but the pre-printed sheet is not in a table format (the boxes where the data goes are in seemingly random positions.)
    I am currently completing the task by laying out a panel in the way I want it and using the printComponent method, but this obviously isnt the best way to do it as all I need to print out is text.
    How is the best way to go about this? Is it possible to define the position of each line of text?
    Cheers. :)

    Well, getting the text from your JTextField should be rather easy: myJTextField.getText().
    To print it, you'll have to create an Graphics object and draw the text using the drawString method on a Graphics objects: myGraphics.drawString(myText, x, y). You will need to set the right font on the graphics before that (using the setFont() method).
    You can then use this Graphics object to print.
    See the java tutorial on printing for more info about printing: http://java.sun.com/docs/books/tutorial/2d/printing/overview.html

  • URGENT: Entering Chinese into Java Text Area

    Hi,
    This might be an FAQ question but some of the info I've gotten over the web so far is conflicting.
    How do I allow a user to enter Chinese text into a Java Text Area (using an english keyboard)?
    All my users have:
    English Windows 2000 with a multilanguage pack. I cannot change this.
    But, I can specify any downloads (IMEs, etc.) and I can choose whichever version of Java I desire.
    Please let me know what is the simplist way to enable Chinese data entry in this environment. Let me know if I need to create my own input type :( or I can use MS Global IME) or if there are other third party chinese input types (even if they are not free).
    Thank you and have a nice day.
    Best Regards,
    Carlos

    Thanks for the note. The news was depressing - but things are much clearer now :) I would like one more clarification, though -
    On the MS site, I quote
    Any user who needs to input East Asian text across the language platforms of Windows Me, Windows 98, Windows 95, or Windows NT 4.0 could use Global IME.
    "Note: On Windows 2000, the Global IMEs work in any application since that OS has full-featured East Asian input support built in. On Windows Millennium, Windows 98, Windows 95, and Windows NT 4.0, the Global IMEs work only in supporting applications."
    When they say they say "full-featured East Asian input support built-in" does that exclude Java? If it would work, would it work with Swing or only AWT?
    Any thoughts? Thanks again for your not, I would greatly appreciate it if you could help me with this clarification.
    Best Regards,
    Carlos

  • Java text parsing

    Hi all!
    I'm a Java beginner and how I have to parse a text file of the form:
    attribute1 1|2|443|554|56
    attribute2 someString
    attribute3 someOtherString
    ...and so on...
    I have to change the value of one of the attributes.
    Could you tell me how to overwrite this attribute.
    Thanx,
    Pesho

    There are some very powerful String tools, which you might want to look at. The first is the Scanner Class http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html , which helps you to tokenize your Strings. It also helps you with regular expressions, which you should look up in the Java tutorial and here: http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/package-frame.html
    A simpler version which is easier to handle is the StringTokenizer Class:
    http://java.sun.com/j2se/1.5.0/docs/api/java/util/StringTokenizer.html
    About changing the file: you just can't change a few bits of your file. You have to read the whole file into some data structure, change the data structure and save it back to disk.

  • Java.text.SimpleDateFormat  with zones

    Hi,
    I have a log file which has a date format as below:
    20091224060656.000000+060
    Wondering if java.text.SimpleDateFormat would be able to parse it properly.I was seeing this API and it didnot have any exact syntax for parsing this kind of date format.
    Please let me know.
    Regards
    Sayan

    sayanb wrote:
    Hi,
    Thank you for the response.The problem is this is one our client's log file which we are trying to parse using the java.text.SimpleDateFormat from our own java application.
    Hence not sure about +060. I guess the part after the . represent the zone , please correct me.But +060 not sure what this means and I dont think java.text.SimpleDateFormat has a way to parse this.
    Please let me know your comments.Uhm, you need to "tell" SimpleDateFormat what the format is, if you don't know how to interpret the format, how are you going to be able to configure SimpleDateFormat. Contact your "client" and make sure you understand the format, then look at the API docs for SimpleDateFormat and hammer out a pattern string for that format. (But I would assume that the "part after the dot" is second fragments (smaller than milliseconds but larger than nanoseconds, about half-way between, what the name for that is, I'm not sure), and that the part with the "plus" is the timezone, probably +060 is the same as +0600.) IOW, you will probably have to "preprocess" the string removing the last three digits before the "plus" and adding a 0 to the end, but that is only a guess.

  • Java.text

    Where on the web can I find a short tutorial as to how to use java.text package?

    The best place to start would be looking at the Javadoc.
    http://java.sun.com/j2se/1.3/docs/api/java/text/package-summary.html
    After you click on a class, most of them have examples right at the beginning of the documentation.
    If that doesn't help search the forum for a specific class. I haven't seen anywhere that does examples of just the java.text package.
    Hope this helps!
    DesQuite

  • Best Java Text Editor

    Which is the best java text editor? I am using Forte for Java but was told JBuilder is better.
    Also does anyone know how to change the view in the Forte program. Ive got seperate windows everywhere.

    I am not using Forte, so I can't answer your second question. As for the first, search the forum, please. That has been asked and answered frequently. The are quite a few tools out there that people like to use and every single one has it's advantages and drawbacks. I would never say that one tool is the best there is, but that I like it the most. An editor that one person finds useful and is comfortable with, is often disliked by someone else... I myself do not like JBuilder, for example. I'd say, try out a few and decide whatyou like the most.

  • Database installation time JAVA (text file busy)

    while installation database 10g show error : jdk/bin/java (text file busy)

    Hi;
    1. What is db version
    2. WHat is EBS version
    3. WHat is OS version
    4. How you get this error, what is compliate error message
    See:
    OTM 5.5 Issue with OTM 5.5 CU5 Installation - ZeroGpf: /opt/otm55prod/jdk/bin/java (Text file busy) [ID 758257.1]
    Regard
    Helios

  • How to pre-configure wireless locations

    Does anyone know how to pre-configure wireless locations that can them be pushed to several computers via ARD?
    We are taking admin rights away from most users, which means they cannot create a wireless location. I need to find a way to have a file or files that are preconfigured with the locations we need (on lab and off site) so they can connect to our private wireless network on lab, and then just plain old dhcp off site. I've tried modifying the preferences.plist and networkinterfaces.plist, but it puts MY computer information throughout, and that is not acceptable.
    I UNIX command or script would be better.
    Any help is appreciated.
    Thanks,
    Lisa

    Hi.
    2 things -
    1. use T3StartupDef interface for startup classes
    (http://edocs.bea.com/wls/docs61/javadocs/weblogic/common/T3StartupDef.html).
    2. check out the example code in
    examples\i18n\logging\startup\UserSMessagesStartupImpl.java. This is a
    startup class that uses T3StartupDef and binds to the JNDI tree.
    Hope this helps,
    Michael
    GSL wrote:
    Michael
    1. But the question is integrating JNDI with some START UP mechanism
    2. I also need a sample of a startup class/tutorial
    Michael Young <[email protected]> wrote:
    Hi.
    Not sure - you might try posting this to the JNDI newsgroup -
    weblogic.developer.interest.jndi.
    Regards,
    Michael
    GSL wrote:
    Hi
    Suppose I need to lookup in message bean an admin email
    in order not to hardcode it
    say ctx.lookup("ADMIN_TO_NOTIFY");
    so in JNDI it is bound to say [email protected]
    Of course I want to configure it somehow so it is dynamic enough
    in some config file
    One way to do it is some tech support servlet that will rebind it
    and init binding thru startup class reading it from customconfig.xml.
    1. Is there a better way to do it???
    config.xml it seems does not allow FULL access to JNDI tree and sois console
    2. Is there a JNDI console for WL?
    3. Is there an example of startup class?
    Thanks--
    Michael Young
    Developer Relations Engineer
    BEA Support
    Michael Young
    Developer Relations Engineer
    BEA Support

  • How to pre-set values to iView form WebDynpro

    Hello
    I'm using  MDM 5.5 Business Package with WebDynpro.
    I want to set the values got by WebDynpro to MDM iView.
    for example,
    In the screen(iView) for creating a record, all input fields are empty at first.
    And then, the values will be set on each fields when the customized button clicks.
    ref
    /people/steffen.ulmer/blog/2006/10/05/extending-mdm-55-business-package-functionality-with-web-dynpro-for-java-using-epcf
    /people/steffen.ulmer/blog/2007/01/03/integrating-mdm-item-details-iview-into-a-webdynpro-application
    I read these blogs, but I don't know how to pre-set values to iView.
    Regards.
    Koji

    Hi,
    try this way..
    go to Se09/Se10-->Click on the trnasport request >go to Tab Object>Prog(R3TR) OBJ(TABU)Object name (<Enter table name>)
    >Next press Include Object>Enter write condiiton  for the table field and retrive the data into transport request for specified Keys.
    http://searchsap.techtarget.com/tip/How-to-transport-table-entries
    Prabhudas

  • How to pre-load Coherence Caches used within an OEP Application

    Hi OEP/Coherence guys,
    I'm currently developing an OEP application that was consuming database inputs in CQL queries.
    I've replaced database direct access by Coherence caches access. My Coherence Local caches use a cache loader to fetch rows (by key) when there is a cache miss. This is working well, and the caches get filled in during the execution of my OEP application.
    The problem is that if CQL queries are made on some attributes (not the key) of not-yet-cached data, the load method of my cache loader is not invoked and there is no result to my CQL query.
    I'm wondering how to pre-load my data in Coherence Caches, from the database, when the OEP application starts to avoid such kind of problems...
    Thx for any advice.
    Renato

    Hi.
    Could you please describe the way to "set-up a cache-loader to load data into your cache when the OEP application starts" ?
    I have a cache-loader configured with my cache. My cache-loader implements the "com.tangosol.net.cache.CacheLoader" interface.
    This interface only defines 2 methods:
    load(java.lang.Object oKey) ==> Return the value associated with the specified key, or null if the key does not have an associated value in the underlying store.
    loadAll(java.util.Collection colKeys) ==> Return the values associated with each the specified keys in the passed collection.
    None of these methods allows me to pre-load my data (and BTW it looks like "loadAll" is never called by OEP)
    Thx
    RP

  • How to pre-compile jsp and deploy to tomcat

    Hi All,
    I wuld like to know how to pre-compile JSPs and deploy to tomcat. I am using ANT tool to build and deploy the war file.
    Thanks in Advance.
    Regards,
    --Nagesh.                                                                                                                                                                                                                                                                                                                                               

    for Tomcat 5.0 (You'll need to edit to fit your needs)
        <path id="jsp.classpath">       
            <!-- point classpath to directory containing jasper-compiler.jar and
                   jasper-runtime.jar -->
            <fileset dir="C:\tomcat\common\lib">
                <include name="**/*.jar"/>
            </fileset>
            <fileset dir="C:/tomcat/common/endorsed">
                <include name="**/*.jar"/>
            </fileset>       
        </path> 
        <target name="jsp" >
        <!--
             The Ant JSPC task doesn't work with Tomcat 5.0
             so in the meantime we need to define our own task.
          -->
        <taskdef name="jspc50" classname="org.apache.jasper.JspC">
            <classpath>
                    <path refid="jsp.classpath"/>    
            </classpath>
        </taskdef>
        <jspc50 outputDir="${build.classes}"
                package="jsp"
                uriroot="${project.dir}/web/webApp"
                webXmlFragment="c:/web.xml"
                verbose="9"
                validateXml="false">           
        </jspc50>
        <javac srcdir="${build.classes}/jsp"
               destdir="${build.classes}"
               debug="true"
               optimize="false"
               includes="**/*.java"
               source="1.4">
                <classpath>
                    <path refid="classpath"/>
                    <path refid="jsp.classpath"/>
                </classpath>          
        </javac>
    </target>    More information can be found here :
    http://www.onjava.com/pub/a/onjava/excerpt/AntTDG_chap8/index1.html?page=last

  • HT204053 Our family uses one Apple ID for all of our iPhones.  We installed the update and now we are all getting each others photos and texts.  How do we stop this?

    Our family uses one Apple ID for all of our iPhone 5's.  We installed the update and now we are all receiving each other's pictures and texts.  How do we stop this? 

    Have a look here...
    http://macmost.com/setting-up-multiple-ios-devices-for-messages-and-facetime.htm l

Maybe you are looking for

  • I can't use my iPod

    This isn't new I'm sure but has Apple made any strides to assist those who have either lost iPod or had their's stolen? I believe "Dateline NBC" ran a story on this very subject and how Apple was not willing, at the time, to get involved. Just curiou

  • Automatic start of Database

    May I know, how to start my own database when i start the system. Like, how it happens in the default database with oracle software.

  • Auto dialer not calling out

    Hi I have a water alarm that I can connect to my BT phone line.  It will call the programmed numbers if there is a water leak. However, I can't get it to call out using my BT phone line. I have taken the devie round to a friend's house and tried it o

  • How to integrate different creator projects

    We have 3 diff creators installed on 3 diff machines we are developing diff modules on these 3 creators. Now we want to integrate all the modules in 1 project(my creator). we cant move classes from 1 project to another as it is time consuming (less R

  • K9N6PGM2-V No Audio

    Hello, Can someone please help, I have 3 MSI K9N6PGM2-V Boards and the onboard audio doesnt seem to work on any of them... I have struggled for hours with these, the drivers have been installed from the CD, then I have also tried the drivers from the