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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:58:09+00:00 2026-06-06T23:58:09+00:00

I’m using struts2.x with jquery date picker. I want to dispaly in the format

  • 0

I’m using struts2.x with jquery date picker.
I want to dispaly in the format dd/mm/yyyy. But from the database when fetching it is coming like yyyy-mm-dd.Then i converted it into the required format but the type is String. So next i Converted it to Date type. But the format is changed.

Date getRiskCommDate()
{
String fString = null;
System.out.println("Coming Date from DB"+riskCommDate);
if(riskCommDate!=null)
{
SimpleDateFormat format = new SimpleDateFormat();
format.applyPattern("dd/MM/yyyy");
fString = format.format(riskCommDate);
}
System.out.println("Formated Date in  String Form "+fString);
Date d = new Date(fString);
System.out.println("Formated Date in Date form Date "+d);
return d;  
}  

Output :

Coming Date from DB 2012-07-04
Formated Date in String Form 04/07/2012
Formated Date in Date form Date Sat Apr 07 00:00:00 IST 2012

Any idea is highly appreciated.

  • 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-06T23:58:12+00:00Added an answer on June 6, 2026 at 11:58 pm

    The java.util.Date class does not have any property to hold a format.

    To display the value of the Date in a custom format, call the format method on SimpleDateFormat.

    When you do this:

    System.out.println(dateInstance)
    

    …you are simply calling the toString() on the Date. That method returns the date in fixed format in String version.

    Based on the comments

    If you anyhow wants the custom format with date instance then you can either create a custom class wrapping date instance

    class MyDate{
      private Date date;
      //provide appropriate accessor
      //override toString() method to support required output
    }
    

    or extend Date

    class MyDate extends Date{
       //override toString() method to support required output
       @Override
       public String toString(){
            //convert `this` to  String with required format with the help of `SimpleDateFormat`
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I want to construct a data frame in an Rcpp function, but when I
I have a view passing on information from a database: def serve_article(request, id): served_article
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text

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.