Reputation: 527
I have a 2-dimensional array which retrieves a date from a database. I want the value to be formatted in days only, "12","13". How can I achieve this this?
This is my code:
String headerQuery = "SELECT DISTINCT attendance FROM Attendance;";
Object[][] headerQueryResult = connectToDB(headerQuery);
for(int x = 0; x < headerQueryResult.length; x++){
for(int y=0; y < headerQueryResult[x].length; y++){
System.out.print(headerQueryResult[x][y]+" ");
}
System.out.println("---");
}
Upvotes: 0
Views: 35
Reputation: 2185
very simple
SimpleDateFormat sdf = new SimpleDateFormat("dd");
int day = Integer.parseInt(sdf.format( dateObject ))
Upvotes: 0
Reputation: 7501
Try this, assuming you're getting an array of dates back.
SimpleDateFormat format = new SimpleDateFormat("dd");
<loop>
System.out.print(format.format((Date) headerQueryResult[x]);
Upvotes: 3