DateFormat.Parse ignores time

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dzenanz
    New Member
    • Feb 2008
    • 45

    DateFormat.Parse ignores time

    Code:
    String input="4/3/08 9:57 AM";
    DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
    StartDate = df.parse(input);
    out.println(StartDate.toLocaleString());//"Apr 3, 2008 12:00:00 AM"
    Java reports locale as en_US, windows regional settings are set to Bosnian (Bosnia and Herzegovina), language to use for non-unicode programs is English (United States). Timezone is Central European Summer Time (UTC +2:00), both in java and in regional settings.

    Is this a bug or am I doing something wrong?
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Use getDateTimeInst ance instead

    [CODE=java]DateFormat df = DateFormat.getD ateTimeInstance (DateFormat.SHO RT, DateFormat.SHOR T );[/CODE]

    Comment

    • dzenanz
      New Member
      • Feb 2008
      • 45

      #3
      That was it. Thank You!

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by dzenanz
        That was it. Thank You!
        Realize also that you are using methods that were deprecated as of JDK version 1.1.

        Comment

        Working...