Posts by hkotsubo • 55,826 points
1,422 posts
-
3
votes2
answers685
viewsA: Fix invalid command dynamically, no alias required
Eventually I discovered that from Bash 4 there is the Command not found Handler, which is a predefined function that is called when a command does not exist. And best of all, you can override this…
-
0
votes1
answer158
viewsA: Java createNativeQuery Insert datetime
SimpleDateFormat is not a date. This class is used to format dates (transform Date for String) and make Parsing (transform String in Date) - see the documentation. If the field in the database is a…
-
3
votes2
answers685
viewsQ: Fix invalid command dynamically, no alias required
I’m using GNU bash version 4.3.46. One problem I have when typing commands, is that I often end up forgetting a space between the command and its parameters. Examples: cd.. gitlog When the right…
-
3
votes1
answer129
viewsA: Different regex strategies to get the same result
In fact, the two regex you indicated do not return the same result. I ran a test on JDK 1.7.0_80, and it is also possible to see them working (differently) here and here. I created a very simple…
-
0
votes1
answer174
viewsA: Data Structure, Double Chained List. Doubt about the Double List Constructor
It was probably done this way because the intention is that you can only create an empty list (without any node). The list always starts empty, and as you add and remove elements, the number of…
-
3
votes1
answer447
viewsA: Data Structure, Circular Queue. Questions about the Queue and Queue methods
If you just add 1, the value of the variable will grow indefinitely. When using %, you are limiting the maximum size that the variable can have. This operator returns the rest of the division, and…
-
1
votes2
answers83
viewsA: Regex - Expression for catching limited fields
Much depends on the variations that the String input can have, and what characters you want to pick up. The simplest case is: (bits.*) That catches bits + everything you have after. Only that .*…
-
0
votes1
answer94
viewsA: Empty function inside another to run script from another file
If I understand correctly, you want a function test which receives a parameter, but which also receives 2 snippets of code to execute before and after processing this parameter, right? If so one way…
-
1
votes1
answer582
viewsA: Calculation of Ruby Factorial
Just for the record, using recursion to calculate factorial is not the most efficient way to do it, and in real applications you shouldn’t use just because it’s possible (prefer the iterative…
-
0
votes1
answer119
viewsA: How to use different implementations from the same interface
Like CalcularFrete is an abstract class, you can leave the method calcularFretePedido abstract: public abstract class CalcularFrete { public abstract double calcularFretePedido(); } Which means the…
-
3
votes2
answers1125
viewsA: Display default date field BR yyyymmdd to dd/mm/yyyy with javascript
Using pure Javascript, you can use the response of Sergio, but using substring instead of split: var str = '20181105'; var ano = Number(str.substring(0, 4)); var mes = Number(str.substring(4, 6));…
-
0
votes2
answers1197
viewsA: How to save to Date type in this format 10-10-2017 using Simpledateformat?
I’m basing myself on in his comment: ... database saved in this format "2017-11-13" and in my program I have to convert a string data = "13-11-2017" to the database formed I mean, at first you have…
-
2
votes1
answer2791
viewsA: Check if date is between two dates in the 30 min range
Based in his comment, you only need to take the date of registration, add 30 minutes and finally compare the date of the new registration with the interval obtained. In this case, your method for…
-
3
votes1
answer156
views -
2
votes1
answer193
viewsA: Instantiate a Map object only when necessary based on a regex
I don’t think gambiarra, although I have my personal opinion as to the use of Reflection in production (which should be moderate, which in your case I think is). But this is just my opinion. Let’s…
-
3
votes3
answers1357
viewsA: Retrieve date and local time of an arbitrary day in an arbitrary Timezone, considering daylight saving time
With native Javascript, the only way is to use a solution similar to what is suggested in Sergio’s response. But if you can use a library, I suggest the Moment js.. To work with time zones, you also…
-
3
votes1
answer2674
viewsA: Validate digital certificate with ICP-Brasil
You can start by looking at 2 certificate information, Issuer and AKI (Authority Key Identifer): The Issuer contains the name of the certifying authority which issued the certificate. To find out…
-
2
votes4
answers2204
viewsA: How to check if a Localdate is a weekend?
To victor’s response is correct, just wanted to add another alternative. Instead of a static method, you can also create a java.time.temporal.TemporalQuery: // TemporalQuery que verifica se é fim de…
-
1
votes2
answers888
views -
1
votes2
answers724
views -
1
votes2
answers786
viewsA: Difference of months between two dates, without considering the day of the month
What happens is that Period.between, in a way, "round down". For an exact month to be considered, the day of the month must be greater than or equal to the beginning. For example, starting on…
-
1
votes1
answer2601
viewsA: Date formatting error when it is on Brazilian daylight saving time (BRST)
Your JVM must still have the old rules of daylight savings time. Until 2017, Brazilian daylight saving time began on the third Sunday in October, but in December 2017 the government changed the rule…