List of utility methods to do Year Format
String | getDDMMYYY_HHMM() get DDMMYYHHMM SimpleDateFormat DDMMYYYY_HHMM = new SimpleDateFormat("ddMMyyyy-HHmm"); return DDMMYYYY_HHMM.format(Calendar.getInstance().getTime()); |
String | getDDMMYYYYDate(Date date) get DDMMYYYY Date return new SimpleDateFormat(DDMMYYYYhifenFormat).format(date); |
String | getFirstDate(String yearMonthStr, String yearMonthFormat, String dateFormat) get First Date DateFormat dfYearMonth = new SimpleDateFormat(yearMonthFormat); DateFormat dfDate = new SimpleDateFormat(dateFormat); java.util.Date date; if (yearMonthStr == null || yearMonthStr.equals("")) { throw new Exception(yearMonthStr + " is invalid."); try { date = dfYearMonth.parse(yearMonthStr); ... |
Date | getFormatToDateSimple(String yyyyMMdd) get Format To Date Simple java.util.Date date = new java.util.Date(); try { yyyyMMdd = yyyyMMdd.replaceAll("/", "").replaceAll(":", ""); java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyyMMdd"); date = formatter.parse(yyyyMMdd); } catch (Exception e) { return null; return date; |
String[] | getStartAndEndWeekOfMonth(int year, int month, int week, String format) get Start And End Week Of Month SimpleDateFormat formater = new SimpleDateFormat(format); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month); calendar.set(Calendar.DATE, 0); int lastWeek = calendar.get(Calendar.WEEK_OF_MONTH); if (week > lastWeek) return null; ... |
String | getStringFormatMMYYWithoutHyphens(Date aDate) get String Format MMYY Without Hyphens SimpleDateFormat myFormatter = new SimpleDateFormat("MMyy"); if (aDate != null) { String myFormattedDate = myFormatter.format(aDate); return myFormattedDate; return null; |
String | getStringFormatYYYYMMddWithHyphens(Date aDate) get String Format YYYYM Mdd With Hyphens SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd"); if (aDate != null) { String myFormattedDate = myFormatter.format(aDate); return myFormattedDate; return null; |
String | getTimeByYMD() get Time By YMD Date date = new Date(System.currentTimeMillis()); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); String dateStr = sdf.format(date); String[] dateArray = dateStr.split("-"); StringBuilder sb = new StringBuilder(); for (int i = 0; i < dateArray.length; i++) { sb.append(dateArray[i]); return sb.toString(); |
int | getYear(SimpleDateFormat df, String dateStr) get Year Calendar c = Calendar.getInstance(); try { c.setTime(df.parse(dateStr)); } catch (ParseException e) { e.printStackTrace(); return c.get(Calendar.YEAR); |
String | getYear(String date, String dateformat) get Year final SimpleDateFormat formatter = new SimpleDateFormat(dateformat); final SimpleDateFormat year = new SimpleDateFormat("yyyy"); return year.format(formatter.parse(date)); |