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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:29:08+00:00 2026-06-13T08:29:08+00:00

I have a method which uses the following lines of code: /* 1 */

  • 0

I have a method which uses the following lines of code:

/* 1 */ DateTimeFormat serverFormat = DateTimeFormat.getFormat("MM/dd/yyyy");
/* 2 */ DateTimeFormat displayFormat = DateTimeFormat.getFormat("MMM dd, yyyy");
/* 3 */ Date thisDate = serverFormat.parse(prices.getCheckInDate());

When I call this method from my test case(Mockito), a NullPointerException occurs at line# 1.

I believe it is happening due to Locale. I don’t know much about Locales. I am pasting the stack trace too.

What is the right way to test it? Can I somehow provide Locale info from my test case?

testSetupMyTable(MyViewTest)java.lang.NullPointerException
    at com.google.gwt.i18n.client.LocaleInfo.ensureDateTimeFormatInfo(LocaleInfo.java:201)
    at com.google.gwt.i18n.client.LocaleInfo.getDateTimeFormatInfo(LocaleInfo.java:159)
    at com.google.gwt.i18n.client.DateTimeFormat.getDefaultDateTimeFormatInfo(DateTimeFormat.java:808)
    at com.google.gwt.i18n.client.DateTimeFormat.getFormat(DateTimeFormat.java:625)


    at MyView.setupMyView(MyView.java:109)
    at MyViewTest.testSetupMyTable(MyViewTest.java:49)
  • 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-13T08:29:09+00:00Added an answer on June 13, 2026 at 8:29 am

    I encapsulated the DateTime formatting logic in a Util class:

    class Util {
      formatDate() {}
    }
    

    And now I am mocking the method of utility class.
    I guess I don’t have to be worried about the testing of DateTimeFormat API as it is already tested.

    In this particular case My test does not require the date conversion to be exact so this solution works fine, but what if I want the date conversion to be exact?

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

Sidebar

Related Questions

I have some code, which uses the ExecuteStmt method on the Axapta Object when
I have the following piece of code which uses the ALAssets library to store
I have a method which uses an index located in a specific directory. public
I have a method, which uses random samples to approximate a calculation. This method
Following this post I have created a WCF client which: Uses ADFS to authenticate
I have the following code inside a method: string username = (string)context[UserName]; string un
I have the following script which uses SocksiPY and Tor: from TorCtl import TorCtl
i have installed cakephp 1.3 which uses the following: Apache Version :2.2.21 PHP Version
I have this method which lets me translate the position of an object, animating
I have this method which leaks ~ 6KB : + (EInspectorFacilityInfo*) newWithNode: (CXMLNode*) node

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.