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 6181637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:03:40+00:00 2026-05-24T01:03:40+00:00

I have written a small method to return a date object when given a

  • 0

I have written a small method to return a date object when given a string. The method is as shown below:

public Date getDateObjectFromString(String dateAsString)
{
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
    Date tempDate = null;

    try
    {
        tempDate = sdf.parse(dateAsString);
    }
    catch(ParseException pe)
    {
        //do some error reporting here
    }
    return tempDate;
}

Everything is working ok, but I’ve run into something that I’d like to clarify. When I pass two different strings to this method it is returning the same date when reading the value in the debugger. The two strings I am passing are:

2011-07-21T19:44:00.000-0400

2011-07-21T19:44:00.000-04:00

As you can see these two strings are nearly identical, and when I look at the variable output for these newly created dates in the debugger, it shows the exact same date/time for either string. So, does the colon in the second string (at 04:00) make any difference if the debugger is showing the same date? Should I worry or can I proceed without any weird bugs popping up later on?

  • 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-24T01:03:41+00:00Added an answer on May 24, 2026 at 1:03 am

    The Android docs for SimpleDateFormat mention that they use RFC 822 timezones. When I went to the JavaDocs for SimpleDateFormat, which is what Android is attempting to mimic with this class, I see this note about RFC 822 timezones:

    RFC 822 time zone: For formatting, the RFC 822 4-digit time zone
    format is used:

     RFC822TimeZone:
             Sign TwoDigitHours Minutes
     TwoDigitHours:
             Digit Digit
    

    TwoDigitHours must be between 00 and 23. Other definitions are as for
    general time zones. For parsing, general time zones are also
    accepted
    .

    And here is the note for general time zones:

    General time zone: Time zones are interpreted as text if they have
    names. For time zones representing a GMT offset value, the following
    syntax is used:

     GMTOffsetTimeZone:
             GMT Sign Hours : Minutes
     Sign: one of          ^^^
             + -
     Hours:
             Digit
             Digit Digit
     Minutes:
             Digit Digit
     Digit: one of
             0 1 2 3 4 5 6 7 8 9
    

    Hours must be between 0 and 23, and Minutes must be between 00 and 59.
    The format is locale independent and digits must be taken from the
    Basic Latin block of the Unicode standard.

    In the definition for the general time zones, you will notice they use a ‘:’.

    This means that your two strings, while different, will be parsed to the same time.

    1. RFC 822 –> 2011-07-21T19:44:00.000-0400
    2. General –> 2011-07-21T19:44:00.000-04:00
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a small webservice[Axis2/Java] which exposes a method public String Fill(String cacheName
I have written a small java application for which I need to obtain performance
I have written a small Perl script and now I would like to create
I have written a small chat app that uses mysql + php to facilitate
I have written a small app that puts my bluetooth in discoverable mode for
I have written a small .net Windows Forms application. And now I decided to
As a Christmas gift I have written a small program in Java to calculate
I am new to the googlemaps API. I have written a small app for
So I am obviously not a very good programmer. I have written this small
I have visual studio 2008. I have a written a small C program. I

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.