Bug 30033 - DateTime parse does not work properly
Summary: DateTime parse does not work properly
Status: RESOLVED DUPLICATE of bug 29570
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 5.1
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2015-05-13 11:38 UTC by Datadec Online
Modified: 2015-05-13 11:42 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Example application (11.61 KB, application/x-zip-compressed)
2015-05-13 11:39 UTC, Datadec Online
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED DUPLICATE of bug 29570

Description Datadec Online 2015-05-13 11:38:47 UTC
I am running a Windows 7.1 x64 operating System with the latest update of Xamarin.Android. When I parse a string with the method StringToDecimal and I test if is higher than 0, returns that is higher. The input string or parameter is "-5" so when parsed to decimal it should be -5 which is not higher than 0.

In the latest version of Xamarin this code was working sucessfully. In fact, it is been almost 3 years working without problems till now.

    private void Test()
    {
      decimal? a = StringToDecimal("-5");

      bool b = a.Value > 0;//it should be false!!!! but is returning true!!!!

      if (b)
        button.Text = "Yes";
      else
        button.Text = "No";
    }

    public static decimal? StringToDecimal(string value)
    {
      if (string.IsNullOrEmpty(value))
        return null;

      try
      {
        if (System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator == ",")
          return decimal.Parse(value.Replace(".", ","));
        else
          return decimal.Parse(value);
      }
      catch
      {
        return null;
      }
    }
Comment 1 Datadec Online 2015-05-13 11:39:22 UTC
Created attachment 11183 [details]
Example application
Comment 2 Jonathan Pryor 2015-05-13 11:42:58 UTC

*** This bug has been marked as a duplicate of bug 29570 ***