Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7898563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:28:00+00:00 2026-06-03T08:28:00+00:00

I wanted to create an extension of java.text.Format but I do not know what

  • 0

I wanted to create an extension of java.text.Format but I do not know what to do with the Format.parseObject method. The javadoc states

Parses text from the beginning of the given string to produce an object. The method may not use the entire text of the given string.

So if you want to implement this method, how do you handle the situation where you can parse the whole input string ? Do you throw an exception or do you return the parsed value (or something else ) ? Note that the javadoc for the exception states that a ParseException is thrown

if the beginning of the specified string cannot be parsed.

IMO, in case where I can parse the whole String, I certainly can parse the beginning so no reason to throw an exception. Looking at the implementation of this method in the JDK, they do not seem to respect their own documentation

public Object parseObject(String source) throws ParseException {
    ParsePosition pos = new ParsePosition(0);
    Object result = parseObject(source, pos);
    if (pos.index == 0) {
        throw new ParseException("Format.parseObject(String) failed",
            pos.errorIndex);
    }
    return result;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T08:28:02+00:00Added an answer on June 3, 2026 at 8:28 am

    “The method may not use the entire text of the given string.”

    You should interpret this as “may or may not…”

    BTW – There are a bunch of built-in Formatters already in java. Aside from NumberFormat & DecimalFormat which are for numbers, the one I like the most (haven’t used in probably 10 yrs – just haven’t had a reason to use it) is java.text.MessageFormat. Go have a look at that and see if it meet your needs

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanted to create some subdirectories inside my blob. But it is not working
From my Ruby C Extension I wanted to create a new Geom::Vector3d instance from
I wanted to create a control with a TextBox and to bind TextBox.Text property
I wanted to create a very simple method that switches between views in a
I wanted to create a page with a simple button which runs away from
I wanted to create jquery plugin & started off creating a sample jquery plugin...But
Is it possible to create an extension method that returns the instance that is
In an extension method how do a create an object based on the implementation
The IEnumerable extension method FirstOrDefault didn't exactly do as I wanted so I created
I'm trying to create an Extension Method for MVC's htmlHelper. The purpose is to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.