| |

VerySource

 Forgot password?
 Register
Search
View: 1363|Reply: 12

Ask for help! Come check it out! The rookie problem Help us a lot! !! !!

[Copy link]

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-3-7 22:30:01
| Show all posts |Read mode
Now want to get the system time
If today is January 1, the system time is 2017001
If today is January 5th, the system time is 2017005
How to achieve it! !! !! !! !!
Waiting online, please help! !! !!
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 Korea, Republic of

Post time: 2020-5-27 21:00:01
| Show all posts
Just ask, what do you want to achieve: 2017 + the number of days in the year today?
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 Great Britain

 Author| Post time: 2020-5-27 21:45:01
| Show all posts
Yes that means
Reply

Use magic Report

0

Threads

9

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-5-28 16:00:01
| Show all posts
java.util.Calendar c = java.util.Calendar.getInstance ();
String s = c.get (java.util.Calendar.YEAR) + "" + c.get (java.util.Calendar.DAY_OF_YEAR);
System.out.println (s);
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-5-28 18:45:01
| Show all posts
I think you should check the API first. If there is a ready-made method, it will be OK.
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-5-31 15:30:02
| Show all posts
java.util.Calendar c = java.util.Calendar.getInstance ();
String s = c.get (java.util.Calendar.YEAR) + "" + c.get (java.util.Calendar.DAY_OF_YEAR);
System.out.println (s);

After this implementation is shown as 20175
What I want is to be able to display 2017005 like this

But thank you very much! ! !
Great guys continue to help! ! !
Reply

Use magic Report

0

Threads

9

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-6-1 10:00:01
| Show all posts
Don't you spell strings?


You are so lazy to get home, I regret to tell you the above procedure.
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-6-1 20:00:01
| Show all posts
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-6-1 20:15:01
| Show all posts
Do I add it manually
String s = c.get (java.util.Calendar.YEAR) + "00" + c.get (java.util.Calendar.DAY_OF_YEAR);
In this way, 2017005 is displayed, and 20175 is displayed without addition


This is not a question of string addition

But thank you anyway! !

<SCRIPT language = javascript> <!-
BirthDay = new Date ("january 01,2000"); // Change to your timing date
today = new Date ();
timeold = (today.getTime ()-BirthDay.getTime ());
sectimeold = timeold / 1000
secondsold = Math.floor (sectimeold);
msPerDay = 24 * 60 * 60 * 1000
e_daysold = timeold / msPerDay
daysold = Math.floor (e_daysold);
e_hrsold = (e_daysold-daysold) * 24;
hrsold = Math.floor (e_hrsold);
e_minsold = (e_hrsold-hrsold) * 60;
minsold = Math.floor ((e_hrsold-hrsold) * 60);
seconds = Math.floor ((e_minsold-minsold) * 60);
//->
</ SCRIPT> <SCRIPT language = javascript> <!-
document.write (2017);
document.write (daysold);
//->
</ SCRIPT>
This can also show your effect
Reply

Use magic Report

0

Threads

14

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 China

Post time: 2020-6-1 20:30:01
| Show all posts
java.util.Calendar c = java.util.Calendar.getInstance ();
String strTemp = "";
if (c.get (java.util.Calendar.DAY_OF_YEAR) <10) {
strTemp = "00" + c.get (java.util.Calendar.DAY_OF_YEAR);
} else {
if (c.get (java.util.Calendar.DAY_OF_YEAR) <100) {
strTemp = "0" + c.get (java.util.Calendar.DAY_OF_YEAR);
} else {
strTemp = "" + c.get (java.util.Calendar.DAY_OF_YEAR);
}
The
}
strTemp = c.get (java.util.Calendar.YEAR) + strTemp;
System.out.println (strTemp);
}
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list