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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:10:41+00:00 2026-05-31T19:10:41+00:00

date here my problem: String datetime = 2012-03-24 23:20:51; I know that that string

  • 0

date here my problem:

String datetime = "2012-03-24 23:20:51";

I know that that string is in UTC timezone.
I need to convert this string to format “yyy-mm-dd’T’HH:mm:ssZ”.

To do this I’m using following code:

    SimpleDateFormat inFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    inFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));
    Date inDate = inFormatter.parse(datetime);
    SimpleDateFormat outFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
    outFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));
    String output = outFormatter.format(inDate);

The problem is that this code is running on a server with timezone UTC+1 and the result it gave me is this:

output = "2012-03-24T21:20:51+0000"

It removes 2 hours from the initial time and puts the UTC timestamp (0000).

Can you please help me solving this?
Thank you.

  • 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-31T19:10:42+00:00Added an answer on May 31, 2026 at 7:10 pm

    If the output format is UTC+1 then you should use that in the outformatter instead of UTC.

    outFormatter.setTimeZone(TimeZone.getTimeZone("UTC+01:00"));
    

    Also, if you don’t want the +0000 at the end then remove the Z

    SimpleDateFormat outFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to do migration date->timestamp with timezone similar to described here: Migrating Oracle
I'm using toLocalizedTime to output a date, as below <span tal:content=python:here.toLocalisedTime(date.get('start_date'))/> This outputs eg.
Date coming out of a database, need to format as mm/dd/yy For Each dr
This is my first question here on stack overflow. i need help on a
I have a problem here and no have ideia to solution this. I have
Here's the problem I'm trying to solve. I want to pass a date, then
I have a datetime string like so: > mydatetime [1] 2012-01-07 14:53:52 EST 2012-01-07
I'm having an issue where a C# DateTime string is failing to convert to
Here I found some problem to maintain one simple date response to get 12
Here I have string like this 1322485986.672901000 , data type is string which represents

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.