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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:39:52+00:00 2026-05-15T16:39:52+00:00

I need to get the day, month, year details from a Date value but

  • 0

I need to get the day, month, year details from a Date value but getYear() is deprecated, gives year on 2 digits, and has problems with Y2K (2008 gives 108). The java doc recommends using java.util.calendar but it is not supported in GWT.

I want to avoid sending all the info back and forth between the server and client just to deal with dates.

Edit: Calendar might be supported Date handling functions should be implemented in GWT futur versions : http://code.google.com/p/google-web-toolkit/issues/detail?id=603

  • 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-15T16:39:52+00:00Added an answer on May 15, 2026 at 4:39 pm

    Do not use those deprecated methods on Date class in GWT.

    If you don’t want to use third party Date implementations for GWT, You use a combination of DateTimeFormat along with string manipulation as a workaround for the time being, until GWT comes up with some better support for manipulating dates.

    For date - 
    DateTimeFormat.getFormat( "d-M-yyyy" ).format( new Date() ).split( "-")[0]
    
    For month - 
    DateTimeFormat.getFormat( "d-M-yyyy" ).format( new Date() ).split( "-")[1]
    
    For year - 
    DateTimeFormat.getFormat( "d-M-yyyy" ).format( new Date() ).split( "-")[2]
    

    Edit-
    Similarly, avoid using new Date( yy, mm, dd ) has come inconsistencies depending on the browser and date range.

    I have use a simple DateUtil Class to create and parse Date objects in GWT, maybe of some use to you –

    (Warning: Very crude, and work in progress)

    public class DateUtil
    {
        private static final String D_M_YYYY = "d-M-yyyy";
        private static final String DATE_SEPARATOR = "-";
    
        public static Date getDate( Integer dd, Integer mm, Integer yyyy )
        {
            if ( dd == null || mm == null || yyyy == null )
                return null;
    
            Date retVal = null;
            try
            {
                retVal = DateTimeFormat.getFormat( D_M_YYYY ).parse( dd + DATE_SEPARATOR + mm + DATE_SEPARATOR + yyyy );
            }
            catch ( Exception e )
            {
                retVal = null;
            }
    
            return retVal;
        }
    
        public static String getDayAsString( Date date )
        {
            return ( date == null ) ? null : DateTimeFormat.getFormat( D_M_YYYY ).format( date ).split( DATE_SEPARATOR )[0];
        }
    
        public static String getMonthAsString( Date date )
        {
            return ( date == null ) ? null : DateTimeFormat.getFormat( D_M_YYYY ).format( date ).split( DATE_SEPARATOR )[1];
        }
    
        public static String getYearAsString( Date date )
        {
            return ( date == null ) ? null : DateTimeFormat.getFormat( D_M_YYYY ).format( date ).split( DATE_SEPARATOR )[2];
        }
    
        public static boolean isValidDate( Integer dd, Integer mm, Integer yyyy )
        {
            boolean isvalidDate = true;
    
            try
            {
                String transformedInput = DateTimeFormat.getFormat( D_M_YYYY ).format( getDate( dd, mm, yyyy ) );
                String originalInput = dd + DATE_SEPARATOR + mm + DATE_SEPARATOR + yyyy;
    
                isvalidDate = transformedInput.equals( originalInput );
            }
            catch ( Exception e )
            {
                isvalidDate = false;
            }
    
            return isvalidDate;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to get the exact start and end dates (month, day and year)
I need to get the last day of the month given as a date
I need to get the hour of day from query with DateTimeProperty field. But,
I'm trying to get the timestamp for:hour:minute am/pm month/day/year but it doesn't seem to
I need to get an NSDate object for 00:00(beginning of the day) from [NSDate
I'm developing an application and I need to get the current date from a
Hey guys i have two date inputs containing three dropboxes for day,month and year
Using NSDateComponents I know how to get the day component, but this gives me
I need to get the first and last day of a month in the
I need to get month and day as :01 for January, 02 for February...

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.