use of com.ibm.icu.util.Calendar in project ofbiz-framework by apache.
the class UtilDateTime method monthBegin.
/**
* Makes a Timestamp for the beginning of the month
*
* @return A Timestamp of the beginning of the month
*/
public static java.sql.Timestamp monthBegin() {
Calendar mth = Calendar.getInstance();
mth.set(Calendar.DAY_OF_MONTH, 1);
mth.set(Calendar.HOUR_OF_DAY, 0);
mth.set(Calendar.MINUTE, 0);
mth.set(Calendar.SECOND, 0);
mth.set(Calendar.MILLISECOND, 0);
mth.set(Calendar.AM_PM, Calendar.AM);
return new java.sql.Timestamp(mth.getTime().getTime());
}
use of com.ibm.icu.util.Calendar in project ofbiz-framework by apache.
the class UtilDateTime method getWeekStart.
public static Timestamp getWeekStart(Timestamp stamp, int daysLater, int weeksLater, TimeZone timeZone, Locale locale) {
Calendar tempCal = toCalendar(stamp, timeZone, locale);
tempCal.set(tempCal.get(Calendar.YEAR), tempCal.get(Calendar.MONTH), tempCal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
tempCal.add(Calendar.DAY_OF_MONTH, daysLater);
tempCal.set(Calendar.DAY_OF_WEEK, tempCal.getFirstDayOfWeek());
tempCal.add(Calendar.WEEK_OF_MONTH, weeksLater);
Timestamp retStamp = new Timestamp(tempCal.getTimeInMillis());
retStamp.setNanos(0);
return retStamp;
}
use of com.ibm.icu.util.Calendar in project ofbiz-framework by apache.
the class UtilDateTime method getDayNames.
/**
* Returns a List of day name Strings - suitable for calendar headings.
* @param locale
* @return List of day name Strings
*/
public static List<String> getDayNames(Locale locale) {
Calendar tempCal = Calendar.getInstance(locale);
tempCal.set(Calendar.DAY_OF_WEEK, tempCal.getFirstDayOfWeek());
SimpleDateFormat dateFormat = new SimpleDateFormat("EEEE", locale);
List<String> resultList = new ArrayList<>();
for (int i = 0; i < 7; i++) {
resultList.add(dateFormat.format(tempCal.getTime()));
tempCal.roll(Calendar.DAY_OF_WEEK, 1);
}
return resultList;
}
use of com.ibm.icu.util.Calendar in project ofbiz-framework by apache.
the class UtilDateTime method getDayEnd.
public static Timestamp getDayEnd(Timestamp stamp, Long daysLater, TimeZone timeZone, Locale locale) {
Calendar tempCal = toCalendar(stamp, timeZone, locale);
tempCal.set(tempCal.get(Calendar.YEAR), tempCal.get(Calendar.MONTH), tempCal.get(Calendar.DAY_OF_MONTH), 23, 59, 59);
tempCal.add(Calendar.DAY_OF_MONTH, daysLater.intValue());
Timestamp retStamp = new Timestamp(tempCal.getTimeInMillis());
retStamp.setNanos(0);
// MSSQL datetime field has accuracy of 3 milliseconds and setting the nano seconds cause the date to be rounded to next day
return retStamp;
}
use of com.ibm.icu.util.Calendar in project ofbiz-framework by apache.
the class UtilDateTime method getYearStart.
public static Timestamp getYearStart(Timestamp stamp, int daysLater, int monthsLater, int yearsLater, TimeZone timeZone, Locale locale) {
Calendar tempCal = toCalendar(stamp, timeZone, locale);
tempCal.set(tempCal.get(Calendar.YEAR), Calendar.JANUARY, 1, 0, 0, 0);
tempCal.add(Calendar.YEAR, yearsLater);
tempCal.add(Calendar.MONTH, monthsLater);
tempCal.add(Calendar.DAY_OF_MONTH, daysLater);
Timestamp retStamp = new Timestamp(tempCal.getTimeInMillis());
retStamp.setNanos(0);
return retStamp;
}
Aggregations