All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.kingsoft.services.util.DateUtils Maven / Gradle / Ivy

There is a newer version: 0.9.91
Show newest version
package com.kingsoft.services.util;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateUtils {
  private static final String DATA_FORMAT_STR = "yyyy-MM-dd HH:mm:ss";

	public static String format(Date date) {
	  DateFormat dateFormat = new SimpleDateFormat(DATA_FORMAT_STR);
		return dateFormat.format(date);
	}

	public static Date parse(String value) throws ParseException {
	  DateFormat dateFormat = new SimpleDateFormat(DATA_FORMAT_STR);
		return dateFormat.parse(value);
	}

	public static String getTimeNow() {
		return format(Calendar.getInstance().getTime());
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy