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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:30:27+00:00 2026-05-25T17:30:27+00:00

I have a field with temporal type as Timestamp to save both date and

  • 0

I have a field with temporal type as Timestamp to save both date and time to the database.

@Temporal(TemporalType.TIMESTAMP)
@Column(name="date", nullable=false)
private Date date;

But when displaying the value to the user, I just want to show date part and truncate time part. I tried this but I get ParseException probably because of the Nanosecond part of the Hibernate Timestamp.

 SimplDateFormat sd = new SimpleDateFormat("MM/dd/yyyy");
 return sd.parse(date.toString());

So how do I retrieve just date from Hibernate Timestamp? Thanks

  • 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-25T17:30:28+00:00Added an answer on May 25, 2026 at 5:30 pm

    Just format the date object. The toString method isn’t guaranteed to give you a string in a format that can then be parsed.

    String dateStr = sd.format(date);
    

    That will give you a date string in MM/dd/yyyy format that you can then convert back into a Date.

    Date fancyNancy = sd.parse(dateStr);
    

    * EDIT *

    Run this code and verify it prints out the day, month and year with no time.

    try {
        Date d = new Date();
        SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy");
        System.out.println("Original Date: " + d);
        System.out.println("Formatted Date: " + df.parse(df.format(d)));
    } catch (Exception e) {
        e.printStackTrace();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a field in my form labeled Name that will contain both the
I have a field in a database that is nearly unique: 98% of the
I have a field (say, foo) in a table in a SQL Server database
I have m2m field, lets say it have name 'relations', so i want to
I have field name category_id in product table. And also I want name field
i have field Tdate (text type) on my Table MyTbl i need query that
Most databases allow to have field with current timestamp (act as creation timestamp), for
I have such models: Class User has_many :comments # have field 'name' in DB
I have form with such field: categories = forms.ModelChoiceField( queryset=Field.objects.all(), widget=CheckboxSelectMultiple, required=False ) And
I have field like a_b_c_d I want as the output a b c_d, this

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.