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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:32:42+00:00 2026-06-15T16:32:42+00:00

The date strings comes from XML feed to my app in format like this

  • 0

The date strings comes from XML feed to my app in format like this Mon, 10 Dec 2012 13:18:23 GMT and I would like to format is as “13:18:23”. I have this method

private String formatTime(String time) {
    DateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy kk:mm:ss zzz", Locale.getDefault());

    String temp = null;

    try {

        temp = df.format(time);

    } catch (IllegalArgumentException e) {
         e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }

    return temp;
}

but I keep getting error IllegalArgumentException.

Anyone can see that is going on with this code?

  • 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-15T16:32:43+00:00Added an answer on June 15, 2026 at 4:32 pm
        String tmp = "Mon, 10 Dec 2012 13:18:23 GMT";
        String DATE_FORMAT = "EEE, dd MMM yyyy kk:mm:ss zzz";
        String DATE_FORMAT_NOW = "kk:mm:ss";
    
        SimpleDateFormat sdfSource = new SimpleDateFormat(DATE_FORMAT);
        Date date = sdfSource.parse(tmp);
    
    
        SimpleDateFormat sdfDestination = new SimpleDateFormat(DATE_FORMAT_NOW);
    
        tmp = sdfDestination.format(date);
    
    
        System.out.println("Converted date is : " + tmp);
    

    Output:

    Converted date is : 15:18:23

    You have difference +2 hours because of GMT. Remove zzz from DATE_FORMAT and you get:

    13:18:23

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

Sidebar

Related Questions

I'd like to convert a bunch of date strings like the following Mon Aug
I would like to create a valid JavaScript Date object from the following string
It is very weird. I hava date format data that comes from Http GET,
When try to convert string value in date-time format some time string variable comes
I'm trying to get the unix time for date strings that are formatted like
Using PHP, I want to convert UNIX timestamps to date strings similar to this:
I want to format a date object so that I can display strings such
Okay so I'm pulling in an XML feed from feedburner, using an XMLDataSource and
String comes back from the database with a format: '00/00/0000' I need to then
Consider a varchar field ( ShipDate ) that gets date-like strings written to it.

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.