Java Timestamp Field getDayOfMonthBy(Timestamp ts)

Here you can find the source of getDayOfMonthBy(Timestamp ts)

Description

get Day Of Month By

License

Open Source License

Declaration

public static int getDayOfMonthBy(Timestamp ts) 

Method Source Code


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

import java.sql.Timestamp;
import java.util.Calendar;

public class Main {

    public static int getDayOfMonthBy(Timestamp ts) {

        Calendar calendar = getCalendar();
        if (ts != null)
            calendar.setTimeInMillis(ts.getTime());

        return calendar.get(Calendar.DAY_OF_MONTH);
    }/*from  w  w  w  .  j  a  v a 2  s  .  c  o  m*/

    public static int getDayOfMonthBy(java.sql.Date date) {

        Calendar calendar = getCalendar();
        if (date != null)
            calendar.setTimeInMillis(date.getTime());

        return calendar.get(Calendar.DAY_OF_MONTH);
    }

    public static int getDayOfMonthBy(long time) {

        Calendar calendar = getCalendar();
        calendar.setTimeInMillis(time);

        return calendar.get(Calendar.DAY_OF_MONTH);
    }

    public static Calendar getCalendar() {

        return getCalendar(null);
    }

    public static Calendar getCalendar(Integer year) {

        return getCalendar(year, null, null);
    }

    public static Calendar getCalendar(Integer year, Integer month) {

        return getCalendar(year, month, null);
    }

    public static Calendar getCalendar(Integer year, Integer month, Integer date) {

        Calendar calendar = Calendar.getInstance();

        if (year != null)
            calendar.set(Calendar.YEAR, year);

        if (month != null)
            calendar.set(Calendar.MONTH, month - 1);

        if (date != null)
            calendar.set(Calendar.DAY_OF_MONTH, date);

        return calendar;
    }
}

Related

  1. getDateTimestamp(ResultSet rs, String columnLabel)
  2. getDateTimeStr(Timestamp timestamp)
  3. getDateTimeString(java.sql.Timestamp ts)
  4. getDayBorder(Timestamp dateTime, Timestamp timeSlot, boolean end)
  5. getDayEnd(java.sql.Timestamp stamp, int daysLater)
  6. getDayOfTime(Timestamp timestamp)
  7. getDayOfWeek(Timestamp timestamp)
  8. getDaysBetween(Timestamp start, Timestamp end)
  9. getDayStartTimestamp()