private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss.SSSSSSS";
public static Date getUtcDatetimeAsDate()
{
return stringDateToDate(getUtcDatetimeAsString());
}
// UTC Now Time get
public static String getUtcDatetimeAsString()
{
final SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
final String utcTime = sdf.format(new Date());
return utcTime;
}
// DATE_FORMAT 형태의 string 을 Date 로 return
public static Date stringDateToDate(String strDate)
{
Date dateToReturn = null;
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
try{
dateToReturn = (Date)dateFormat.parse(strDate);
}catch (ParseException e) {
e.printStackTrace();
}
return dateToReturn;
}