Java Timestamp Field getDayOfWeek(Timestamp timestamp)

Here you can find the source of getDayOfWeek(Timestamp timestamp)

Description

get Day Of Week

License

Open Source License

Parameter

Parameter Description
timestamp a parameter

Declaration

public static int getDayOfWeek(Timestamp timestamp) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.sql.Timestamp;

import java.util.Calendar;
import java.util.Date;

public class Main {

    public static int getDayOfWeek(Timestamp timestamp) {
        Calendar cal = Calendar.getInstance();
        Date date = new Date(timestamp.getTime());
        cal.setTime(date);/*from  w  ww.j  a  v  a  2  s  . c om*/
        int dayForWeek = 0;
        dayForWeek = cal.get(Calendar.DAY_OF_WEEK);
        if (dayForWeek == 1) {
            dayForWeek = 7;
        } else {
            dayForWeek = dayForWeek - 1;
        }
        return dayForWeek;
    }
}

Related

  1. getDateTimeString(java.sql.Timestamp ts)
  2. getDayBorder(Timestamp dateTime, Timestamp timeSlot, boolean end)
  3. getDayEnd(java.sql.Timestamp stamp, int daysLater)
  4. getDayOfMonthBy(Timestamp ts)
  5. getDayOfTime(Timestamp timestamp)
  6. getDaysBetween(Timestamp start, Timestamp end)
  7. getDayStartTimestamp()
  8. getDayTime(Timestamp day, Timestamp time)
  9. getDefaultTimestamp()