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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:24:37+00:00 2026-06-14T09:24:37+00:00

I am working with groovy (gremlin to traverse a graph database to be exact).

  • 0

I am working with groovy (gremlin to traverse a graph database to be exact). Unfortunately, because I am using gremlin, I cannot import new classes.

I have some date values that I wish to convert to a Unix timestamp. They are stored as UTC in the format: 2012-11-13 14:00:00:000

I am parsing it using this snippet (in groovy):

def newdate = new Date().parse("yyyy-M-d H:m:s:S", '2012-11-13 14:00:00:000')

The problem is that it does a timezone conversion, which results in:

Tue Nov 13 14:00:00 EST 2012

And if I then convert that to a timestamp using time(), that gets converted to UTC, then the timestamp generated.

How do I get new Date() to not do any timezone conversions when the date is first parsed (and just assume the date as UTC)?

  • 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-14T09:24:38+00:00Added an answer on June 14, 2026 at 9:24 am

    Here are two ways to do it in Java:

    /*
     *  Add the TimeZone info to the end of the date:
     */
    
    String dateString = "2012-11-13 14:00:00:000";
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-d H:m:s:S Z");
    Date theDate = sdf.parse(dateString + " UTC");
    

    /*
     *  Use SimpleDateFormat.setTimeZone()
     */
    
    String dateString = "2012-11-13 14:00:00:000";
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-d H:m:s:S");
    sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
    Date theDate = sdf.parse(dateString);
    

    Note that Date.parse() is deprecated (so I did not recommend it).

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

Sidebar

Related Questions

I am working on a project using Groovy, and I would like to take
I'm working on a Java/Groovy program. I have a double variable that holds a
I have a Groovy application. I am rendering the view list using the following
Invoking a groovy script using CLASSPATH prefix as follows works fine: CLASSPATH=/path/to/classes groovy -e
I'm working on extending a legacy script system using groovy. The source scripts are
I'm working on a new Groovy app which uses log4j for logging, but when
I have a working little application made in Groovy. At the moment I can
what I have: an external GroovyScript using the apache-commons-io library and a working grails
I have a Java application that is running embedded groovy scripts using a GroovyClassLoader
I'm working in Groovy 1.8.6, running on JDK 1.6.0u33. When my program is starting

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.