Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have to import a CVS file containing 120k rows. The first 6 columns contain the date and time separately, ie: year, month, day, hour, minutes, seconds.

I imported them into Java:

int year = 2016
int month = 5
int day = 23
int hour = 15
int minutes = 57
int seconds = 22 

How can I convert this format to a format compatible with MySQL (DATETIME)?

I also have a GMT column, i.e. "GMT +0200". Can I convert this data too in a DATETIME?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
658 views
Welcome To Ask or Share your Answers For Others

1 Answer

One way you could do this is to build your string in this format:

yyyy-MM-DD HH:mm:ss

Then insert it.

INSERT INTO yourtable VALUES('2016-05-23 15:57:22')


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...