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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:44:29+00:00 2026-05-26T23:44:29+00:00

Is it possible to format a date time in Java using the SimpleDateFormat class

  • 0

Is it possible to format a date time in Java using the SimpleDateFormat class to give the timezone part of a date without having the +0000 after it.

Edit

We are changing the Default Timezone within Java as follows:

SimpleTimeZone tz = new SimpleTimeZone(0, "Out Timezone");        
TimeZone.setDefault(tz);

Unfortunately, I am in no position to remove this code. I would hazard a guess at the whole system stopping working. I think the initial author put this in to work around some day light saving issues.

With this in mind, I want to format the date as:

2011-12-27 09:00 GMT

or

2011-12-27 09:00 BST

I can only get the SimpleDateFormat to output as:

2011-12-27 09:00:00 GMT+00:00

which uses the format string yyyy-MM-dd HH:mm:ss z

I cannot see anywhere where the simple timezone has any reference to winter time (GMT) id or summer time id (BST).

  • 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-26T23:44:30+00:00Added an answer on May 26, 2026 at 11:44 pm

    Not an elegant solution at all but it works for us. I had to create a custom implementation for DateFormat/SimpleDateFormat. This looks like something as follows:

    static {
        // this would be initialized like something as follows when the application starts
        // which causes the headaches of SimpleDateFormat not to work...
        SimpleTimeZone tz = new SimpleTimeZone(0, "Out Timezone");             
        TimeZone.setDefault(tz);  
    }
    
    // therefore this class will workaround the issue, 
    
    public class OurOwnCustomDateFormat
        extends SimpleDateFormat {
    
        /** The pattern to use as the format string. */
        protected String pattern;
    
        public OurOwnCustomDateFormat(String pattern) {
             super(pattern);
             // store the pattern
             this.pattern = pattern;
        }
    
        @Override
        public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition pos) {
    
             // custom implementation to format the date and time based on our TimeZone            
             toAppendTo.insert(pos.getBeginIndex(), "the date with our custom format calculated here");
             return toAppendTo; 
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using android.text.format.DateFormat.format(yyyy-MM-dd hh:mm:ss, new java.util.Date()) to get time & date. The problem
Hello in my database date / time are in this format 2010-06-01T18:20:25+0000 I'd like
Possible Duplicate: PHP/MySQL - Format date/time I have input field (name:day1 and varchar) to
I have to format date/time in my gwt app with specific timezone, which is
Possible Duplicate: How to change format of date/time? In my program I'm making an
I'd like to use date time format string (possibly UTC) which is understandable and
Is it possible to customize a django application to have accept localized date format
Is it possible to format price according to rules like this using DecimalFormat in
Is it possible using StAX (specifically woodstox) to format the output xml with newlines
How can I parse a string that represents a date and/or time using iPhone

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.