necesito para recuperar años día y mes a partir de un objeto de marca de tiempo como números largos:cómo recuperar el día de mes y el año de la marca de hora (formato largo)
public long getTimeStampDay()
{
String iDate = new SimpleDateFormat("dd/MM/yyyy")
.format(new Date(born_date.getDate()));
.....
return day; //just the day
}
public long getTimeStampMonth()
{
String iDate = new SimpleDateFormat("dd/MM/yyyy")
.format(new Date(born_date.getDate()));
.....
return month; //just month
}
public long getTimeStampYear()
{
String iDate = new SimpleDateFormat("dd/MM/yyyy")
.format(new Date(born_date.getDate()));
.....
return year; //just year
}
born_date
es un objeto de marca de tiempo.
¿Es posible hacer eso?
Gracias de antemano.
Hola, en mi caso, el tipo de variable "bornDate" es "java.sql.Timestamp". Me gustaría recuperar el año de "fecha de nacimiento". "getYear()" está en desuso, pero "getDate()" está en desuso también ... Entonces, ¿qué se debe hacer? Gracias. –
El tipo "bornDate" es "java.sql.Timestamp". El siguiente código hace el truco: Calendar calendar = Calendar.getInstance(); calendar.setTime (bornDate); System.out.println (calendar.get (Calendar.YEAR)); –