Repository navigation
Expand file tree
/
Copy pathCalendario.java
More file actions
70 lines (60 loc) · 1.76 KB
/
Copy pathCalendario.java
File metadata and controls
70 lines (60 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ModelClass;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
/**
*
* @author AlexJPZ
*/
public class Calendario {
private DateFormat dateFormat;
private Date date = new Date();
private Calendar c = new GregorianCalendar();
private String fecha, Dia, Mes, year, hora, minutos, segundos, am_pm;
private int mes;
public Calendario() {
// hora = Integer.toString(c.get(Calendar.HOUR));
// minutos = Integer.toString(c.get(Calendar.MINUTE));
// segundos = Integer.toString(c.get(Calendar.SECOND));
switch (c.get(Calendar.AM_PM)) {
case 0:
am_pm = "am";
break;
case 1:
am_pm = "pm";
break;
}
dateFormat = new SimpleDateFormat("dd");
Dia = dateFormat.format(date);
dateFormat = new SimpleDateFormat("MM");
Mes = dateFormat.format(date);
dateFormat = new SimpleDateFormat("yyyy");
year = dateFormat.format(date);
dateFormat = new SimpleDateFormat("dd/MM/yyyy");
fecha = dateFormat.format(date);
dateFormat = new SimpleDateFormat("hh:mm:ss");
hora = dateFormat.format(date) + " " + am_pm;
}
public String getFecha() {
return fecha;
}
public String getHora() {
return hora;
}
public String getDia() {
return Dia;
}
public String getMes() {
return Mes;
}
public String getYear() {
return year;
}
}