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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:08:43+00:00 2026-06-16T04:08:43+00:00

Now it’s like this, I have a long variable with date and time on

  • 0

Now it’s like this, I have a long variable with date and time on it. So I use DateFormat to get the date and time for itself, and now I want to get the year, month, day, hour and minutes for itself. The date and time is in a String, so actually I could just cut the string with substring and all that. But since like for example Sweden has their date like this: “dd/mm/yyyy”, and the US has their date like this: “mm/dd/yyyy”. So if I just cut the String for the Swedish date, the day variable will become the month.

This is my code:

String start = mCursor.getLong(1);

Format df = DateFormat.getDateFormat(this);
Format tf = DateFormat.getTimeFormat(this);

String date = df.format(start);
String time = tf.format(start);

So my question is, is there someway to get the year, month, day, hour and minute for itself in a own String?

Thanks in advance, GuiceU. (Bad english, I know)

  • 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-16T04:08:45+00:00Added an answer on June 16, 2026 at 4:08 am

    I wouldn’t do it that way. Use java.util.Calendar:

    DateFormat dateFormatter = new SimpleDateFormat("yyyy-MMM-dd");
    dateFormatter.setLenient(false);
    String dateStr = "2012-Dec-21";
    Date date = dateFormatter.parse(dateStr);
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(date);
    int month = calendar.get(Calendar.MONTH);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Now facebook require to have these options when you want to use bulit-in actions
Now I have a long query and I'd like to alternate with such a
Now layout look like this What I want to achieve is this <style type=text/css>
Now I have routing set up like this. resources :communities do resources :community_topics end
Now that I know C++ I want to get into desktop application that have
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Now I have a string just including uppercases and lowercases. I want to change
Now my folded lines look like this: +-- 123 lines: doSomeStuff();-------------------------- +-- 345 lines:
this is what i have right now Drawing an RSS feed into the php,
Now this is a weird one We have a project where we are reading

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.