Java Utililty Methods String to Time

List of utility methods to do String to Time

Description

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

Method

Date[]getMReportTime(String time)
get M Report Time
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM");
Date date = dateFormat.parse(time);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) + 1);
calendar.set(Calendar.DAY_OF_MONTH, 0);
Date[] dates = new Date[2];
dates[1] = calendar.getTime();
...
GregorianCalendargetSignTime(final String stStr)
get Sign Time
if (stStr == null) {
    return new GregorianCalendar();
Date date;
final SimpleDateFormat formatter = new SimpleDateFormat("yyyy:MM:dd:HH:mm:ss"); 
try {
    date = formatter.parse(stStr);
} catch (final Exception e) {
...
StringgetStringWithTime(String str)
get String With Time
DateFormat dateFormat = DateFormat.getTimeInstance();
return "(" + dateFormat.format(new Date()) + ") " + str;
StringgetSystemTime(String pattern)
Gets the system time.
long secs = System.currentTimeMillis();
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
Date date = new Date(secs);
return sdf.format(date);
DategetTime(String date)
get Time
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return sdf.parse(date);
longgetTime(String date, String pattern)
get Time
try {
    return parseDate(date, pattern).getTime();
} catch (ParseException e) {
    e.printStackTrace();
return 0;
longgetTime(String dateTimeString)
get Time
long time = 0;
try {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date date = sdf.parse(dateTimeString);
    time = date.getTime();
} catch (Exception e) {
    e.printStackTrace();
    time = 0;
...
StringgetTime(String file)
get Time
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(new File(file).lastModified()));
StringgetTime(String parrten)
get Time
String timestr;
if (parrten == null || parrten.equals("")) {
    parrten = "yyyyMMddHHmmss";
java.text.SimpleDateFormat sdf = new SimpleDateFormat(parrten);
java.util.Date cday = new java.util.Date();
timestr = sdf.format(cday);
return timestr;
...
StringgetTime(String pattern)
get Time
return new SimpleDateFormat(pattern).format(new Date());