List of usage examples for java.util Date setTime
public void setTime(long time)
From source file:org.myjerry.util.ServerUtils.java
public static Date getUniversalDate(String string) { Date date = new Date(); date.setTime(Long.valueOf(string)); return date;/*w w w . j av a 2s . c o m*/ }
From source file:org.myjerry.util.ServerUtils.java
public static Date getUniversalDate(Long time) { Date date = new Date(); date.setTime(time); return date;// w w w . java 2s . c o m }
From source file:FileStatus.java
public static void status(String fileName) throws IOException { System.out.println("---" + fileName + "---"); // Construct a File object for the given file. File f = new File(fileName); // See if it actually exists if (!f.exists()) { System.out.println("file not found"); System.out.println(); // Blank line return;// w w w . ja v a 2 s . com } // Print full name System.out.println("Canonical name " + f.getCanonicalPath()); // Print parent directory if possible String p = f.getParent(); if (p != null) { System.out.println("Parent directory: " + p); } // Check if the file is readable if (f.canRead()) { System.out.println("File is readable."); } // Check if the file is writable if (f.canWrite()) { System.out.println("File is writable."); } // Report on the modification time. Date d = new Date(); d.setTime(f.lastModified()); System.out.println("Last modified " + d); // See if file, directory, or other. If file, print size. if (f.isFile()) { // Report on the file's size System.out.println("File size is " + f.length() + " bytes."); } else if (f.isDirectory()) { System.out.println("It's a directory"); } else { System.out.println("I dunno! Neither a file nor a directory!"); } System.out.println(); // blank line between entries }
From source file:Main.java
public static Date getdatebyDays(int DAYS) { Date today = new Date(); Long Before_Date = (today.getTime() / 1000) - 60 * 60 * 24 * DAYS; today.setTime(Before_Date * 1000); return today; }
From source file:Main.java
public static String getDatebyDays(int DAYS) { Date today = new Date(); Long Before_Date = (today.getTime() / 1000) - 60 * 60 * 24 * DAYS; today.setTime(Before_Date * 1000); return format.format(today); }
From source file:com.jennifer.ui.util.TimeUtil.java
public static Date get(long d) { Date newDate = new Date(); newDate.setTime(d); return newDate; }
From source file:com.example.amazon.mw.exempli.ExempliClient.java
static String getConcertDate() { long newTime = System.currentTimeMillis() + 7 * 24 * 60 * 60 * 1000; // Add 7 days to current time. Date futureDate = new Date(); futureDate.setTime(newTime); SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy"); return format.format(futureDate); }
From source file:Main.java
public static String getPreTime(String sj1, String jj) { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String mydate1 = ""; try {/*from w w w .j a v a 2 s . com*/ Date date1 = format.parse(sj1); long Time = (date1.getTime() / 1000) + Integer.parseInt(jj) * 60; date1.setTime(Time * 1000); mydate1 = format.format(date1); } catch (Exception e) { } return mydate1; }
From source file:Util.java
/** * Sets the time on the same day to 00:00:00.000 * * @param date/*from w w w .j a v a 2 s .co m*/ * @return a new date */ @SuppressWarnings("deprecation") public static Date truncateTime(Date date) { Date newDate = (Date) date.clone(); newDate.setHours(0); newDate.setMinutes(0); newDate.setSeconds(0); newDate.setTime(newDate.getTime() - newDate.getTime() % 1000); //Millisekunden auf 0 return newDate; }
From source file:Main.java
public static String getNextDay(String nowdate, String delay) { try {// w ww . j a v a 2 s. co m SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); String mdate = ""; Date d = strToDate(nowdate); long myTime = (d.getTime() / 1000) + Integer.parseInt(delay) * 24 * 60 * 60; d.setTime(myTime * 1000); mdate = format.format(d); return mdate; } catch (Exception e) { return ""; } }