use of com.ibm.icu.util.Calendar in project ofbiz-framework by apache.
the class UtilDateTime method getLatestDate.
public static Date getLatestDate() {
Calendar cal = getCalendarInstance(TimeZone.getTimeZone("GMT"), Locale.getDefault());
cal.set(Calendar.YEAR, cal.getActualMaximum(Calendar.YEAR));
cal.set(Calendar.MONTH, cal.getActualMaximum(Calendar.MONTH));
cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
cal.set(Calendar.HOUR_OF_DAY, 23);
cal.set(Calendar.MINUTE, 59);
cal.set(Calendar.SECOND, 59);
cal.set(Calendar.MILLISECOND, 999);
return cal.getTime();
}
use of com.ibm.icu.util.Calendar in project ofbiz-framework by apache.
the class UtilDateTime method toDateString.
/**
* Makes a date String in the given from a Date
*
* @param date The Date
* @return A date String in the given format
*/
public static String toDateString(java.util.Date date, String format) {
if (date == null) {
return "";
}
SimpleDateFormat dateFormat = null;
if (format != null) {
dateFormat = new SimpleDateFormat(format);
} else {
dateFormat = new SimpleDateFormat();
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return dateFormat.format(date);
}
use of com.ibm.icu.util.Calendar in project ofbiz-framework by apache.
the class UtilDateTime method getEarliestDate.
public static Date getEarliestDate() {
Calendar cal = getCalendarInstance(TimeZone.getTimeZone("GMT"), Locale.getDefault());
cal.set(Calendar.YEAR, cal.getActualMinimum(Calendar.YEAR));
cal.set(Calendar.MONTH, cal.getActualMinimum(Calendar.MONTH));
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();
}
use of com.ibm.icu.util.Calendar in project ofbiz-framework by apache.
the class UtilDateTime method weekNumber.
public static int weekNumber(Timestamp input, int startOfWeek) {
Calendar calendar = Calendar.getInstance();
calendar.setFirstDayOfWeek(startOfWeek);
if (startOfWeek == Calendar.MONDAY) {
calendar.setMinimalDaysInFirstWeek(4);
} else if (startOfWeek == Calendar.SUNDAY) {
calendar.setMinimalDaysInFirstWeek(3);
}
calendar.setTime(new java.util.Date(input.getTime()));
return calendar.get(Calendar.WEEK_OF_YEAR);
}
use of com.ibm.icu.util.Calendar in project ofbiz-framework by apache.
the class UtilDateTime method getMonthNames.
/**
* Returns a List of month name Strings - suitable for calendar headings.
*
* @param locale
* @return List of month name Strings
*/
public static List<String> getMonthNames(Locale locale) {
Calendar tempCal = Calendar.getInstance(locale);
tempCal.set(Calendar.MONTH, Calendar.JANUARY);
SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM", locale);
List<String> resultList = new ArrayList<>();
for (int i = Calendar.JANUARY; i <= tempCal.getActualMaximum(Calendar.MONTH); i++) {
resultList.add(dateFormat.format(tempCal.getTime()));
tempCal.roll(Calendar.MONTH, 1);
}
return resultList;
}
Aggregations