How to get the name of the day from java sql.Timestamp
object such as Monday, Tuesday?
If ts
is your Timestamp
object then to get the month in string format:
String month = (new SimpleDateFormat("MMMM")).format(ts.getTime()); // "April"
and for the day of the week:
String day = (new SimpleDateFormat("EEEE")).format(ts.getTime()); // "Tuesday"
You convert your java.sql.Timestamp to a java.sql.Date and send it through a Calendar.
java.sql.Timestamp ts = rs.getTimestamp(1);
java.util.GregorianCalendar cal = Calendar.getInstance();
cal.setTime(ts);
System.out.println(cal.get(java.util.Calendar.DAY_OF_WEEK));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With