Created
September 21, 2017 08:30
-
-
Save na5imuzzaman/440e160df06a2c6f4cf18d2891f65e43 to your computer and use it in GitHub Desktop.
Current Time Code in JAVA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
@author Nasimuzzaman Nasim | |
*/ | |
import javax.swing.JOptionPane; | |
import java.text.DecimalFormat; | |
public class Main | |
{ | |
public static void main(String args[]) | |
{ | |
DecimalFormat df1 = new DecimalFormat("00"); | |
long miliS = System.currentTimeMillis(); | |
long sec = miliS/1000; | |
int currSec = (int) sec%60; | |
long min = sec/60; | |
int currMin = (int) min%60; | |
long hour = min/60; | |
int currHour = (int) (hour-1)%24; | |
String time; | |
if (currHour>12) | |
{ | |
currHour = currHour%12; | |
time = "PM"; | |
} | |
else | |
time = "AM"; | |
JOptionPane.showMessageDialog(null,df1.format (currHour) + " : " | |
+ df1.format(currMin) + " : " + df1.format(currSec) + " " + time, | |
"Current BD Time",JOptionPane.INFORMATION_MESSAGE); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment