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

  • Home
  • SEARCH
  • 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 6544501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:28:23+00:00 2026-05-25T11:28:23+00:00

So I have a Date object and I want to create a method so

  • 0

So I have a Date object and I want to create a method so that it prints the Date in the following format:

11 September 2011, 9:15pm

How do I do that?
As of now I am just doing a toString to the date and it gives me all the GMT information and seconds precision that I don’t need. Do I have to use a DateFormatter or is there an easier way to do this?

This was edited to include Java ME in the title and the tags after some of the answers that were correct for the original question were posted.

  • 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-25T11:28:24+00:00Added an answer on May 25, 2026 at 11:28 am

    You may use SimpleDateFormat class to format your date.
    http://download.oracle.com/javase/1,5.0/docs/api/java/text/SimpleDateFormat.html

    I guess the pattern would be something like this:

    SimpleDateFormat format = new SimpleDateFormat("dd MMMM yyyy, h:ma");
    format.format(yourDate);
    

    EDIT for Java ME;
    I read that there is no SimpleDateFormat class in Java ME specs. So I would try Calendar;

    First put your date to the Calendar, then get all you need. Better is make this a method

    Calendar calendar = Calendar.getInstance();
    Date myDate = new Date(); // as an example, date of "now"
    calendar.setTime(myDate);
    
    int day = calendar.get(Calendar.DAY_OF_MONTH);
    int monthNumber = calendar.get(Calendar.MONTH);
    
    String[] _months = new DateFormatSymbols().getMonths();
    String[] months = new String[12];
    for(int i =0; i < 12; i++){
        months[i] = _months[i];
    }
    //because there is something wrong, we have a 12. month in the name of "" (nothing)
    
    //or if there is no DateFormatSymbols class in your plans
    //you may write for yourself;
    /*
    String[] monthNames = {"January", "February",
                "March", "April", "May", "June", "July",
                "August", "September", "October", "November",
                "December"};
    */
    String month = months[monthNumber]; //or String month = monthNames[monthNumber];
    
    int year = calendar.get(Calendar.YEAR);
    
    int hour = calendar.get(Calendar.HOUR);
    int minute = calendar.get(Calendar.MINUTE);
    String amPm = calendar.get(Calendar.AM_PM)==1 ? "am" : "pm";
    System.out.println(day + " " + month + " " + 
        year + ", " + hour + ":" + minute + amPm);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a date object, and have the time saved as I
I want to create an application that logs when I have gone jogging and
I have following XML generated by serializing a boost::posix_time::ptime structure. I want to create
I have a list of Date objects, and a target Date. I want to
I have been trying to add to the Watch window a Java Date object
On a JSTL/JSP page, I have a java.util.Date object from my application. I need
Let's say I have an object: public class CustomObj { DateTime Date { get;
I have two Zend Date objects to work with: $now = Zend_Date::now(); $sessionStart =
I have a bunch of objects that have a value and a date field:
I have the following NSString : NSString * dateString = @2012-01-24T14:59:01Z; I want to

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.