java convert timestamp to date and time
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateTest {
public static void main(String[] args) {
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
Date date = new Date(timestamp.getTime());
System.out.println(date);
SimpleDateFormat simpleDateFormats = new SimpleDateFormat("MM/dd/yyyy");
System.out.println(simpleDateFormats.format(date));
// S is the millisecond
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm:ss");
System.out.println(simpleDateFormat.format(timestamp));
System.out.println(simpleDateFormat.format(date));
}
}
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateTest {
public static void main(String[] args) {
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
Date date = new Date(timestamp.getTime());
System.out.println(date);
SimpleDateFormat simpleDateFormats = new SimpleDateFormat("MM/dd/yyyy");
System.out.println(simpleDateFormats.format(date));
// S is the millisecond
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm:ss");
System.out.println(simpleDateFormat.format(timestamp));
System.out.println(simpleDateFormat.format(date));
}
}
相關文章
- JAVA裡的String、Timestamp、Date相互轉換Java
- date、timestamp欄位型別型別
- oracle plsql定義date_timestamp_with time zoneOracleSQL
- Java:String和Date、Timestamp之間的轉換Java
- mysql資料庫date 、datetime、time、timestamp區別MySql資料庫
- Unable to convert MySQL date/time value to System.DateTimeMySql
- oracle timestamp轉換date及date型別相減Oracle型別
- Mysql日期(DATE, TIME, DATETIME, TIMESTAMP)型別的比較MySql型別
- Oracle中Date和Timestamp的區別Oracle
- 將timestamp轉成date格式的指令碼指令碼
- How to Convert a Date Time to “X minutes ago” in C# zGoC#
- 面試題:能談談Date、Datetime、Time、Timestamp、year的區別嗎?面試題
- date和timestamp型別之間的轉換型別
- String和Date、Timestamp之間的轉換
- 將timestamp型別轉換為date型別型別
- ORACLE DATE型別和TIMESTAMP型別DUMP換算Oracle型別
- oracle資料型別date和timestamp的轉化Oracle資料型別
- [20111229]date time timestamp? ansi liternals.txt
- python date 和 datetime 的取值範圍(對比 Mysql 的 datetime 和 timestamp)PythonMySql
- timestamp with local time zone型別和timestamp with time zone型別
- mysql中的date、datetime、timestamp你還不知道怎麼使用嗎MySql
- java8 Date/Time APIJavaAPI
- Oracle timestamp_to_scn and scn_to_timestampOracle
- ORACLE DATE和TIMESTAMP資料型別的比較(一) (轉)Oracle資料型別
- ORACLE DATE和TIMESTAMP資料型別的比較(二) (轉)Oracle資料型別
- TIMESTAMP和TIMESTAMP WITH TIME ZONE之間的總結
- 如何將UTC時間轉換為Unix時間戳(How to convert UTC time to unix timestamp)時間戳
- Oracle TimestampOracle
- 6、TIMESTAMP WITH TIME ZONE和TIMESTAMP WITH LOCAL TIME ZONE的實踐理解
- java:Date和DateTime區別Java
- oracle 中關於當前的sysdate,sysstimestap,current_date,curent_timestamp 區別Oracle
- ORA-00001 : Unique Constraint Violated caused by DATE VS Timestamp(6)AI
- Oracle timestamp型別轉換date格式指令碼(精確到秒)Oracle型別指令碼
- mysql CURRENT_TIMESTAMP 和ON UPDATE CURRENT_TIMESTAMPMySql
- [Warning] TIMESTAMP with implicit DEFAULT --explicit_defaults_for_timestamp
- MySQL: datetime vs timestampMySql
- partitioned by timestamp datatype
- MySQL之timestampMySql