Java Utililty Methods Now

List of utility methods to do Now

Description

The list of methods to do Now are organized into topic(s).

Method

StringgetTimeNowAsString(String pattern)
get Time Now As String
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
return sdf.format(getDateNow());
longgetTimeSubFromNowTime(String time)
get Time Sub From Now Time
int year = Integer.parseInt(getLocationCurrentDate().split("-")[0]);
int month = Integer.parseInt(getLocationCurrentDate().split("-")[1]);
int day = Integer.parseInt(getLocationCurrentDate().split("-")[2]);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
    Date date = format.parse(year + "-" + month + "-" + day + " " + time);
    Date now = new Date();
    return date.getTime() - now.getTime();
...
StringgetValidDate(String unknownDate)
get Valid Date
if (unknownDate == null || !unknownDate.matches("[\\+|-]?[0-9]+")) {
    return null;
Calendar calendar = Calendar.getInstance();
int len = unknownDate.length();
if (len < 4) { 
    int days = Integer.parseInt(unknownDate);
    calendar.add(Calendar.DAY_OF_MONTH, days);
...
booleanisNowInInterval(String start, String end)
is Now In Interval
return isHourInInterval(getCurrentHour(), start, end);
StringmakeUniqueName(final String[] knownNames, final String pattern)
Computes a unique name using the given known-names array as filter.
final HashSet<String> knownNamesSet = new HashSet<String>(knownNames.length);
for (int i = 0; i < knownNames.length; i++) {
    final String name = knownNames[i];
    knownNamesSet.add(name);
final MessageFormat message = new MessageFormat(pattern);
final Object[] objects = { "" };
final String plain = message.format(objects);
...
Stringnow()
now
return now(DEFAULT_TSFORMAT);
Stringnow()
Retorna a Data do sistema ignorando a hora minuto segundo.
java.util.Date dt = new Date();
String ds = fmt.format(new Date());
return ds;
Stringnow()
Get a string representation of the the current time
Calendar cal = Calendar.getInstance();
return DateFormat.getTimeInstance().format(cal.getTime());
Stringnow()
now
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dt = sdf.format(new Date());
return dt;
Stringnow()
Returns the current Date/Time in "iTunes time format"
return formatter.format(new Date());