Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Arredondamento de datas para dias 10, 20 e 30
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_72 import java.util.*; import java.lang.*; import java.util.Date; class Rextester { public static void main(String args[]) { Integer dias = 45; Calendar c = Calendar.getInstance(); c.setTime(new Date()); System.out.println("dia recebido = "+c.getTime()); c.add(Calendar.DAY_OF_MONTH, +dias); System.out.println("dia recebido + 20 dias = "+c.getTime()); Integer dia = c.get(Calendar.DAY_OF_MONTH); if(dia <= 4 || dia >= 25){ if(dia<=4){ c.set(Calendar.MONTH,c.get(Calendar.MONTH)-1); } dia = 30; } else if(dia <= 14 && dia >= 5){ dia = 10; } else if(dia <= 24 && dia >= 15){ dia = 20; } c.set(Calendar.DAY_OF_MONTH, dia); System.out.println("data correta:"+c.getTime()); } }
run
|
edit
|
history
|
help
0
Convert string array to lowercase.
Java Variable
Black Jack by Craig
jb6.13 varargs
3a
Hi
reverse integer
circleapp.java
Brackets balancing
decToBin