Fechas en Java
Comparar fechas en java:
comparar-dos-fechas-en-Java
COMPARAR-FECHAS_-1_0_1
bigdecimal-compareto-function-in-java
// Java program to demonstrate compareTo() method
import java.io.*;
import java.math.*;
public class GFG {
public static void main(String[] args)
{
// Creating 2 BigDecimal objects
BigDecimal b1, b2;
b1 = new BigDecimal(67891);
b2 = new BigDecimal(12346);
if (b1.compareTo(b2) == 0) {
System.out.println(b1 + " and " + b2 + " are equal.");
}
else if (b1.compareTo(b2) == 1) {
System.out.println(b1 + " is greater than " + b2 + ".");
}
else {
System.out.println(b1 + " is lesser than " + b2 + ".");
}
}
}
comparar-dos-fechas-en-Java
COMPARAR-FECHAS_-1_0_1
bigdecimal-compareto-function-in-java
// Java program to demonstrate compareTo() method
import java.io.*;
import java.math.*;
public class GFG {
public static void main(String[] args)
{
// Creating 2 BigDecimal objects
BigDecimal b1, b2;
b1 = new BigDecimal(67891);
b2 = new BigDecimal(12346);
if (b1.compareTo(b2) == 0) {
System.out.println(b1 + " and " + b2 + " are equal.");
}
else if (b1.compareTo(b2) == 1) {
System.out.println(b1 + " is greater than " + b2 + ".");
}
else {
System.out.println(b1 + " is lesser than " + b2 + ".");
}
}
}
Output:
67891 is greater than 12346.
Comentarios
Publicar un comentario