Java Date Set setField(Date date, int field, int value)

Here you can find the source of setField(Date date, int field, int value)

Description

set Field

License

LGPL

Declaration

public static Date setField(Date date, int field, int value) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

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

public class Main {
    public static Date setField(Date date, int field, int value) {
        Date result = date;//w w w. ja v  a 2  s .c o  m
        if (date != null) {
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(date);
            calendar.set(field, value);
            result = calendar.getTime();
        }
        return result;
    }
}

Related

  1. setDateHourMinute(Date dateParam, String hourMinute, String format)
  2. setDateSecond(Date dateParam, int second)
  3. setDateToDayStart(final Date date)
  4. setDateToStartOfDay(Date date)
  5. setDayStart(final Date date)
  6. setHour(java.util.Date date, Integer hour)
  7. setHourMinuteSecondToZeroPlus24Hours(Date datetime)
  8. setHours(Date d, int hours)
  9. setHours(Date date, int amount)