-
Current month of the year format mm
CURRENT_MONTH_YEAR
Date now = new Date();
int month = now.getMonth() + 1;
String monthStr = month.toString();
if (month < 10) monthStr = '0' + monthStr;
returnValue(monthStr);
- Current year format yyyy
Date now = new Date();
int year = now.getYear() + 1900;
String yearStr = year.toString();
returnValue(yearStr);
- Current month format mm/yyyy
Date now = new Date();
int month = now.getMonth() + 1;
String monthStr = month.toString();
if (month < 10) monthStr = '0' + monthStr;
int year = now.getYear() + 1900;
String toReturn = monthStr + '/' + year.toString();
returnValue(toReturn);
- Current date format dd/mm/yyyy
Date now = new Date();
int day = now.getDate();
String dayStr = day.toString();
if (day < 10) dayStr = '0' + dayStr;
int month = now.getMonth() + 1;
String monthStr = month.toString();
if (month < 10) monthStr = '0' + monthStr;
int year = now.getYear() + 1900;
String toReturn = dayStr + '/' + monthStr + '/' + year.toString();
returnValue(toReturn);