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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:44:34+00:00 2026-06-17T02:44:34+00:00

i have tried some thing like this package com.poc; import java.util.Date; import java.text.DateFormat; import

  • 0

i have tried some thing like this

package com.poc;

import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;


public class GetCurrentDateTime {
  public static void main(String[] args) {

       DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
       //get current date time with Date()
       Date date = new Date();
       System.out.println(dateFormat.format(date));

       //get current date time with Calendar()
       Calendar cal = Calendar.getInstance();
       System.out.println(dateFormat.format(cal.getTime()));

  }
}

and my out put is : 2013-01-07 17:12:27 but want the output to be like this 2013-Jan-07 17:12:27 PM

how to do this in java?

Best Regards

  • 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-17T02:44:35+00:00Added an answer on June 17, 2026 at 2:44 am

    your format should be

    new SimpleDateFormat("dd-MMM-yy hh:mm:ss a");
    

    07-Jan-13 07:20:02 PM

    new SimpleDateFormat("dd-MMM-yy HH:mm:ss");
    

    07-Jan-13 19:20:02

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

Sidebar

Related Questions

If I have the following class: package com.example; import org.springframework.beans.factory.annotation.Required; public class Customer {
Complete new person to Ruby and Rails here... Have tried some tutorials in the
I have tried to find some articles on my problem, but haven't found anything
I have tried to get some information from W3C regarding the update of an
I have tried to find some decent documentation on traversing in jQuery, but have
I have tried to do some reading about it, but I failed to find
I have tried to compile some C++ WIN32 code with GCC through DevC++ (MinGW
In the following example (apologies for the length) I have tried to isolate some
I'm new in soapclient, I have tried to do some study online and also
I have tried to solve the problems related to circular dependency in some files

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.