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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:49:35+00:00 2026-05-18T09:49:35+00:00

Here is my code to fetch and display date: import java.util.Calendar; public class Employee

  • 0

Here is my code to fetch and display date:

import java.util.Calendar;
        
public class Employee {
     private Calendar doj; 
     public Employee(Calendar date) {
     // TODO Auto-generated constructor stub
        this.doj=date;
        }
        public Calendar getDoj() 
        { 
        return doj; 
        } 
        
     }
    
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
    
public class TestEmployeeSort {
    
  /**
    * @param args
   */
    public static void main(String[] args) {
    // TODO Auto-generated method stub
        List<Employee> coll = getEmployees();
        printList(coll);
    }
        public static List<Employee> getEmployees() 
        { 
            List<Employee> col = new ArrayList<Employee>();
              
            col.add(new Employee(Calendar.getInstance()));
            return col;
        } 
        private static void printList(List<Employee> list) { 
            System.out.println("Date_Of_Joining"); 
         
            for (int i = 0; i < list.size(); i++) { 
                Employee e = list.get(i); 
                System.out.println(e.getDoj()); 
            } 
        } 
    }

The above code produces the following output:

Date_Of_Joining
java.util.GregorianCalendar[time=1291275522078,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Asia/Calcutta",offset=19800000,dstSavings=0,useDaylight=false,transitions=6,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2010,MONTH=11,WEEK_OF_YEAR=49,WEEK_OF_MONTH=1,DAY_OF_MONTH=2,DAY_OF_YEAR=336,DAY_OF_WEEK=5,DAY_OF_WEEK_IN_MONTH=1,AM_PM=1,HOUR=1,HOUR_OF_DAY=13,MINUTE=8,SECOND=42,MILLISECOND=78,ZONE_OFFSET=19800000,DST_OFFSET=0]

What I want to do is simply to print the date alone. Here, my output contains way too much data that I don’t need. How should I change the code to achieve this?

  • 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-18T09:49:36+00:00Added an answer on May 18, 2026 at 9:49 am

    Well personally I’d use Joda Time (and its LocalDate class, if you really only want to maintain the date) rather than java.util.Calendar, but if you do want to use Calendar, you need a SimpleDateFormat.

    java.util.Calendar sample:

    import java.util.*;
    import java.text.*;
    
    public class Test
    {
        public static void main(String[] args)
        {
            Calendar calendar = Calendar.getInstance();
            SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
            System.out.println(format.format(calendar.getTime()));
        }
    }
    

    Joda Time sample:

    import org.joda.time.*;
    import org.joda.time.format.*;
    
    public class Test
    {
        public static void main(String[] args)
        {
            LocalDate today = new LocalDate();
            // Alternatively, use DateTimeFormat.mediumDate etc
            DateTimeFormatter formatter = DateTimeFormat.forPattern("dd/MM/yyyy");
            System.out.println(formatter.print(today));
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my code @Entity class Parent extends Person { @OneToMany(cascade = CascadeType.ALL, fetch
Here a code to demonstrate an annoying problem: class A { public: A(): m_b(1),
Here is the MYSQLi code: public function display() { $sql = SELECT title, date_posted,
Here is source code: @OneToOne(fetch = FetchType.LAZY) @Cascade({SAVE_UPDATE, EVICT, DELETE}) @JoinColumn(name = A_ID, nullable
here is my code i am using to fetch mysql result from 4 different
I am trying to display blogs on a certain page here is my code:
I modified the code here (http://www.w3schools.com/PHP/php_ajax_database.asp) to update and display my database after an
The script is on jsfiddle here : CODE What it does at the moment
Ok the error is showing up somewhere in this here code if($error==false) { $query
Here is code my jqgrid editing through form. $(#DataEnergy).jqGrid('navGrid', '#pagergrid', {}, //options {editdata: {

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.