Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Exception in thread "main" java.util.UnknownFormatConversionException: Conversion = '0'

  1. #1
    Junior Member
    Join Date
    Apr 2013
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Exception in thread "main" java.util.UnknownFormatConversionException: Conversion = '0'

    Hi been trying to figure out what am not getting right in the code below
    public String to chioma(){
    		return String.format("%d:%02d:%02 %s", ((hour==0||hour==12)?12:hour%12), minute, seconds,(hour < 12? "AM": "PM"));
    	}
    .

    when i run, it shows error(as shown below):

    //Exception in thread "main" java.util.UnknownFormatConversionException: Conversion = '0'
    at java.util.Formatter.checkText(Formatter.java:2519)
    at java.util.Formatter.parse(Formatter.java:2483)
    at java.util.Formatter.format(Formatter.java:2430)
    at java.util.Formatter.format(Formatter.java:2383)
    at java.lang.String.format(String.java:2781)
    at prac.TimeClass.chioma(TimeClass.java:19)
    at prac.TimeMain.main(TimeMain.java:7)//

    i' ll be grateful to have your help. thanks
    Last edited by pbrockway2; April 27th, 2013 at 02:22 AM. Reason: code tags edited


  2. #2
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default Re: Exception in thread "main" java.util.UnknownFormatConversionException: Conversion = '0'

    I think you left out the "d" where the seconds are formatted.

  3. #3
    Junior Member
    Join Date
    Apr 2013
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Exception in thread "main" java.util.UnknownFormatConversionException: Conversion = '0'

    THANKS, WOW,DIDNT SEE IT. THANKS!

  4. #4
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default Re: Exception in thread "main" java.util.UnknownFormatConversionException: Conversion = '0'

    You're welcome.

Similar Threads

  1. Replies: 1
    Last Post: April 7th, 2013, 03:40 PM
  2. Replies: 11
    Last Post: August 30th, 2012, 02:30 PM
  3. Replies: 3
    Last Post: December 7th, 2011, 02:03 AM
  4. Replies: 6
    Last Post: November 12th, 2010, 04:40 AM
  5. Replies: 2
    Last Post: March 23rd, 2010, 01:38 AM