List of usage examples for java.sql Date Date
public Date(long date)
From source file:Main.java
public static Date dateToSQLDate(java.util.Date d) { return d != null ? new Date(d.getTime()) : null; }
From source file:Main.java
public static String convertUnixToString(long unixTimeInMillis) { Date time = new Date(unixTimeInMillis * 1000); String timeString = new SimpleDateFormat("dd MMM yyyy", Locale.getDefault()).format(time); return timeString; }
From source file:Main.java
public static String convertTime(long time) { Date date = new Date(time); Format format = new SimpleDateFormat("HH:mm:ss dd.MM.yyyy", Locale.getDefault()); return format.format(date); }
From source file:Main.java
public static String getFileName(String suffix) { Date date = new Date(System.currentTimeMillis()); SimpleDateFormat dateFormat = new SimpleDateFormat("'xc'_yyyyMMddHHmmss", Locale.CHINESE); String randomNumber = "_" + new Random().nextInt(10000); return dateFormat.format(date) + randomNumber + suffix; }
From source file:Main.java
public static String getCurrentTime() { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); Date date = new Date(System.currentTimeMillis()); return sdf.format(date); }
From source file:Main.java
public static String getNowDate() { SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd"); Date date = new Date(System.currentTimeMillis()); return sf.format(date); }
From source file:Main.java
public static String getTimeStamp_1() { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss", Locale.US); Date curDate = new Date(System.currentTimeMillis()); return formatter.format(curDate); }
From source file:Main.java
public static String getTimeStamp_2() { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss:SSS", Locale.US); Date curDate = new Date(System.currentTimeMillis()); return formatter.format(curDate); }
From source file:Main.java
public static String get_date(String args) { // long nowTime=System.currentTimeMillis(); long retime = Integer.valueOf(args).intValue(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); String date = sdf.format(new Date(retime * 1000)); return date;/*from w w w . j a va 2s .co m*/ // System.out.print(date); }
From source file:Main.java
/** * String to date. e.g. 2013-12-13/* w w w . j av a 2 s. c o m*/ * * @param dateStr * @return */ public static Date str2Date(String dateStr) { try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date date = new Date(sdf.parse(dateStr).getTime()); sdf = null; return date; } catch (ParseException e) { return null; } }