+2 votes
by (100 points)

Why would

 DateTime.TryParseExact("08/10/2013", "dd/MM/yyyy", null, DateTimeStyles.None, out dateValue)  

return false?

7 Answers

+16 votes
by (100 points)

Use CultureInfo.InvariantCulture instead of null .

It tells the compiler that the format is culture-independent.

DateTime.TryParseExact("08/10/2013", 
                       "dd/MM/yyyy", 
                       CultureInfo.InvariantCulture, 
                       DateTimeStyles.None, 
                       out dateValue);`

If you use null , it is inferred as CultureInfo.CurrentCulture (msdn: "If provider is null, the CultureInfo object that corresponds to the current culture is used" ). Also, since it's not that clear, the problem is that / is replaced by the provided culture's date-separator. It has a special meaning. http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx#dateSeparator

Here is a running example

enter image description here

+14 votes
by (100 points)

Because you passed null for the IFormatProvider parameter. Try passing CultureInfo.InvariantCulture instead

EDIT As others mentioned, the actual reason is that / in the string to parse is itself translated using the rules provided by IFormatProvider . When you pass null the default value of CultureInfo.CurrentCulture is used.

+9 votes
by (100 points)

My solution:

public static bool IsValidDateTime(string sDateTime){ bool ret = false;

    string[] formats = {
        "dd/MM/yyyy HH:mm:ss",
        "yyyy-MM-dd HH:mm:ss",
        "yyyy-MM-ddTHH:mm:sszzz"
    };

    try{
        DateTime.ParseExact(sDateTime, formats, CultureInfo.InvariantCulture, DateTimeStyles.None); 
        ret = true;
    }
    catch{}

    return ret;
}       
+4 votes
by (100 points)

Can I assign any value to n without it overflowing?

There are limits to what a BigInteger can represent. As the javadoc says:

" BigInteger must support values in the range -2 Integer.MAX_VALUE (exclusive) to +2 Integer.MAX_VALUE (exclusive) and may support values outside of that range."

Later on, it says:

" BigInteger constructors and operations throw ArithmeticException when the result is out of the supported range ..."

... so you don't get unannounced overflows (like you do with primitive integer types) or INF/NaN-like values (like floating point types).


There is also the issue that if the heap is full / too small, creation of a large BigInteger will throw an OOME.


If overflow is the problem ...

In your example, overflow in the BigInteger code it is not the problem. You would be seeing exceptions of some kind.

Furthermore the expression 512*512*512 doesn't overflow. (But in general, you could get an overflow in the constructor argument expressions ... because those calculations are typically done using primitive integer arithmetic, which overflows silently.)

(Pedantically ... the assignment n = p; is a reference assignment, and cannot overflow or throw an OOME. AFAIK, there is no way that it can fail within the context of the Java model. You'd need a hardware error, power failure, heap corruption, code generation bug, etc ...)

0 votes
by (100 points)

You might have overrode the Semantic UI css with your own css for the textarea. It doesn't look weird if you just use the default semantic files. Check your custom css files.

$('.ui.dropdown').dropdown();
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/1.11.8/semantic.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/1.11.8/semantic.min.js"></script>
<table class = "ui celled stripped table">
        <thead>
            <tr>
                <th>
                    Nombre
                </th>
                <th>
                    Personalidad
                </th>
                <th>
                    Pide extensión
                </th>
                <th>
                    Contexto
                </th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td class = "collapsing">
                    Nombre nombre apellido apellido
                </td>
                <td class = "collapsing">
                    <div class = "ui multiple search selection dropdown" dropdown-search-personalities>
                        <input type = "hidden">
                        <i class = "dropdown icon"></i>
                        <div class = "default text">Selecciona...</div>
                        <div class = "menu">

                        </div>
                    </div>
                </td>
                <td class = "collapsing">
                    <div class="ui fitted slider checkbox">
                      <input type="checkbox"> <label></label>
                    </div>
                </td>
                <td class = "collapsing">
                    <textarea></textarea>
                </td>
            </tr>
        </tbody>
    </table>
0 votes
by (100 points)

Yup there is one :

In your app/channel/what_so_ever_you_called_it.rb:

class WhatSoEverYouCalledItChannel < ApplicationCable::Channel
     def subscribed
       stream_from "your_streamer_thingy"
       @subscriber +=1 #<==== like this
     end

     def unsubscribed
       # Any cleanup needed when channel is unsubscribed 
       @subscriber -=1 #<===== like this
     end
     def send_message(data)
        your_message_mechanic
     end

Setup a variable increasing in subscribed and decreasing in unsubscribed.

You may want store the value in your 'lobby' model , in this case '@subscriber' may be called @lobby.connected_total, i dont know, make this fit your needs.

But this is a way to keep track of number of stream.

Njoy

0 votes
by (100 points)

When calling API use executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); instead of execute() . It may resolve your issue of slowing down memory.

Related questions

+11 votes
7 answers
+3 votes
10 answers
...