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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:42:48+00:00 2026-05-27T00:42:48+00:00

I am having a quite annoying problem. I want to get the current date/time

  • 0

I am having a quite annoying problem. I want to get the current date/time and insert it into a filename but I can’t for my life get it to work.

I want to get the time as 2011-11-18 12:13:57 and then insert it into my filename

filename-2011-11-18-12:13:57.tar.gz

I have tried SimpleDateFormat etc. but it just won’t work!

(I am writing in Eclipse Indigo)

  • 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-27T00:42:48+00:00Added an answer on May 27, 2026 at 12:42 am

    You can use this:

    import java.text.SimpleDateFormat;
    // ...
    
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss", Locale.US);
    Date now = new Date();
    String fileName = formatter.format(now) + ".tar.gz";
    

    Also you must be getting an error somewhere, that would help a lot to find the problem. Make sure you don’t have empty catch blocks :

    catch (Exception e) {}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm quite new to OpenId and I'm having a bit of a problem understanding
Have looked quite hard for this answer but having no luck. I have 3
My model is quite simple but I'm having some problems with the vector I'm
I am having some trouble creating a nested association and I can't quite spot
I have been struggling with this for quite some time having been accustomed to
I'm having quite a problem deciding how to serve a few Python scripts. The
I'm having quite some trouble with the WCF Callback mechanism. They sometimes work but
I'm having quite the problem now. It's only bothering in Firefox (Testing with FF10),
I'm having quite a hard time on constructing my 1st XML Schema. I need
I'm having quite a frustrating problem that I'm sure is TRIVIAL. Whenever I move

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.