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

  • SEARCH
  • Home
  • 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 6374823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:32:11+00:00 2026-05-25T01:32:11+00:00

I am trying to format a date like these august 2011, and august 24,2011

  • 0

I am trying to format a date like these

august 2011, and august 24,2011

I am using this to parse them now..

//set the pattern here to look like the pattern you are expecting in your 'Date' variable
                    SimpleDateFormat sdf = new SimpleDateFormat("MMMM dd,yyyy");

 //Get the release date
                     releaseDate = postIt.next().text();

                     Date realDate = null;
                    try {
                        realDate = sdf.parse(releaseDate);
                    } catch (ParseException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } 

                     int i = 0;
                    String gameDate =  realDate.toString();

i get the following error in my debug.

08-26 22:02:44.571: WARN/System.err(29218): java.text.ParseException: Unparseable date: "August 2011" (at offset 11)
08-26 22:02:44.571: WARN/System.err(29218):     at java.text.DateFormat.parse(DateFormat.java:626)

How would i go about making this to where it will read both formats?

EDIT:

This is how it parses it now…

08-27 00:10:48.951: VERBOSE/Dates(30449): August 2011  

If formated the August 2011
to

08-27 00:10:48.951: ERROR/FormattedDATE(30449): Mon Aug 01 00:00:00 EDT 2011

They all parse to this same date.

  • 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-05-25T01:32:12+00:00Added an answer on May 25, 2026 at 1:32 am

    I think you’ll need a format string for each e.g.

    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    
    public class DateFormatDriver {
        public static void main( String[] args ) throws Exception {
    
            SimpleDateFormat dayMonthYearFormatter = new SimpleDateFormat("MMMM dd,yyyy");
            SimpleDateFormat monthYearFormatter = new SimpleDateFormat("MMMM yyyy");                
    
            //String date1 = "August 11,2005";
            String date1 = "August 2005";
            Date realDate = null;
    
            try {
                realDate = dayMonthYearFormatter.parse(date1);
                System.out.println("parsed date -> " + realDate);
            } catch (ParseException e) {                    
                // fall back on other formatter
                try {               
                    realDate = monthYearFormatter.parse(date1);
                    System.out.println("parsed date -> " + realDate);
                } catch(ParseException e2) {
                    System.err.println("could not parse" + date1);              
                }
            }                          
        }        
    }
    

    I would recommend you check out http://joda-time.sourceforge.net

    This is just an idea, not sure if I’d really use it but a tokenizer could be used to see what date type it is, 2 tokens for ‘August 11, 2005’, 1 for ‘August 2005’. So use one formatter if token count is 1, other formatter if token count is 2 e.g.

        int tokenCount = 0;
        StringTokenizer tokenizer = new StringTokenizer("August 11, 2005", ",");
        while(tokenizer.hasMoreTokens()) {
            tokenizer.nextToken();
            tokenCount++;
        }
        System.out.println("token count -> " + tokenCount);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to output dates in the Italian format using date() as follows:
I'm trying to format large currency numbers like this: NSNumber *testVal = [NSDecimalNumber decimalNumberWithString:
I've seen this: how to get formatted date time like 2009-05-29 21:55:57 using javascript?
I'm trying to validate date using PHP. I'd like following formats to be valid:
With ruby I'm trying to get format a date as such: 2009-10-01 Where I
I'm trying to figure out a way to format a date string that sits
Does anybody know which date format is to be used, trying to create a
I'm trying to print out the date in a certain format: NSDate *today =
I'm trying to format a column in a <table/> using a <col/> element. I
While trying to transform the date format I get an exception:unparseable date and don't

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.