List of usage examples for java.sql Timestamp Timestamp
public Timestamp(long time)
From source file:Main.java
public static Timestamp toTimestamp(XMLGregorianCalendar xmlDate) { if (xmlDate == null) return null; return new Timestamp(xmlDate.toGregorianCalendar().getTime().getTime()); }
From source file:com.dc.gameserver.extComponents.Kit.time.DateFormatUtil.java
/** * formate time yyyy-MM-dd HH:mm:ss/* w ww . j av a 2 s . co m*/ * @return */ public static String getDateFormatA() { long nowTime = System.currentTimeMillis(); Timestamp timestamp = new Timestamp(nowTime); return DateFormatUtils.format(timestamp, "yyyy-MM-dd HH:mm:ss"); }
From source file:MainClass.java
public static Timestamp makeTimestamp(int year, int month, int day, int hour, int minute, int second, int millisecond) { Calendar cal = new GregorianCalendar(); cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, month - 1); cal.set(Calendar.DATE, day);/*from w w w . j a va2 s . c o m*/ cal.set(Calendar.HOUR_OF_DAY, hour); cal.set(Calendar.MINUTE, minute); cal.set(Calendar.SECOND, second); cal.set(Calendar.MILLISECOND, millisecond); // now convert GregorianCalendar object to Timestamp object return new Timestamp(cal.getTimeInMillis()); }
From source file:Main.java
@SuppressLint("SimpleDateFormat") public static String getHMS(String time) { long timestamp = Long.parseLong(time); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); try {/* ww w . ja v a 2s .co m*/ String str = sdf.format(new Timestamp(timestamp)); return str; } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return time; }
From source file:Main.java
public static Timestamp subtractTimeZoneOffset(Timestamp timestamp, TimeZone timeZone) { final long millisecondsToSubtract = Math.abs(timeZone.getOffset(timestamp.getTime())); return new Timestamp(timestamp.getTime() - millisecondsToSubtract); }
From source file:com.dc.gameserver.extComponents.Kit.time.DateFormatUtil.java
/** * formate time HH:mm:ss/*from w ww.j av a2 s . co m*/ * @return */ public static String getDateFormatB() { long nowTime = System.currentTimeMillis(); Timestamp timestamp = new Timestamp(nowTime); return DateFormatUtils.format(timestamp, "HH:mm:ss"); }
From source file:Main.java
public static Timestamp xmlGregorianCalendarToTimestamp(XMLGregorianCalendar xgc) { if (xgc == null) { return null; }//from www .j a v a2s . c om GregorianCalendar gc = xgc.toGregorianCalendar(); return new Timestamp(gc.getTimeInMillis()); }
From source file:com.ibm.mil.readyapps.telco.analytics.OperationalAnalyticsReporter.java
/** * planChangeAccepted() sends an Operational Analytics log anytime a user accepts a plan change. * * @param planChangeType the type of plan change that a user has accepted (ie baseplan * increase, baseplan decrease, addon, etc) * @param amount the cost amount of the plan change. *///from ww w .jav a2 s . c o m public static void planChangeAccepted(@AnalyticsCnsts.PlanChange String planChangeType, double amount) { // Create a custom activity with a log message Date date = new Date(); Timestamp curTime = new Timestamp(date.getTime()); String json = gson.toJson(new AnalyticsPlanChange(planChangeType, amount, curTime), AnalyticsPlanChange.class); JSONObject jsonObject = null; try { jsonObject = new JSONObject(json); jsonObject.put("_activity", "planChanged"); Log.i("TEST", "JSON AFTER ACTIVITY " + jsonObject.toString()); WLAnalytics.log("Plan change accepted by a user", jsonObject); //async } catch (JSONException e) { e.printStackTrace(); } }
From source file:Main.java
public static String getFormattedTimeStamp(long millisSince1970) { Timestamp stamp = new Timestamp(millisSince1970); SimpleDateFormat formatDate = new SimpleDateFormat(MARTUS_SIGNATURE_FILE_DATE_FORMAT); String dateStamp = formatDate.format(stamp); return dateStamp; }
From source file:Main.java
public final static Timestamp getTodayMidnight() { GregorianCalendar calendar = new GregorianCalendar(); calendar.set(GregorianCalendar.HOUR_OF_DAY, 0); calendar.set(GregorianCalendar.MINUTE, 0); calendar.set(GregorianCalendar.SECOND, 0); calendar.set(GregorianCalendar.MILLISECOND, 0); return new Timestamp(calendar.getTimeInMillis()); }