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
public class Decimal2Hexadecimal { | |
public static void main(String[] args) { | |
String hex1 = Integer.toHexString(16); | |
System.out.println(hex1); | |
String hex2 = Integer.toHexString(128); | |
System.out.println(hex2); | |
String hex3 = Integer.toHexString(255); |
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
public class Hexadecimal2Decimal { | |
public static void main(String[] args) { | |
String hex = "ff"; | |
int dec = Integer.parseInt(hex, 16); | |
System.out.println(dec); | |
} | |
} |
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
public class Decimal2Binary { | |
public static void main(String[] args){ | |
String b1 = Integer.toBinaryString(1); | |
System.out.println(b1); | |
String b2 = Integer.toBinaryString(12); | |
System.out.println(b2); | |
String b3 = Integer.toBinaryString(123); |
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
public class Binary2Decimal { | |
public static void main(String[] args) { | |
String bin = "10101110"; | |
int dec = Integer.parseInt(bin, 2); | |
System.out.println(dec); | |
} | |
} |
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
import java.sql.Timestamp; | |
import java.util.Date; | |
public class TimestampToDate { | |
public static void main(String[] args) { | |
Timestamp ts = new Timestamp(System.currentTimeMillis()); | |
System.out.println(ts); | |
Date date = new Date(ts.getTime()); | |
System.out.println(date); |
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
import java.sql.Timestamp; | |
import java.util.Date; | |
public class DateToTimestamp { | |
public static void main(String[] args) { | |
Date date = new Date(); | |
Timestamp ts = new Timestamp(date.getTime()); | |
System.out.println(ts); | |
} | |
} |
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
public class BooleanToString { | |
public static void main(String[] args) { | |
boolean b1 = true; | |
String s1 = String.valueOf(b1); | |
System.out.println("Vlera është: " + s1); | |
boolean b2 = false; | |
String s2 = String.valueOf(b2); | |
System.out.println("Vlera është: " + s2); |
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
public class StringToBoolean { | |
public static void main(String[] args) { | |
String s1 = "true"; | |
boolean b1 = Boolean.parseBoolean(s1); | |
System.out.println(b1); | |
String s2 = "TRUE"; | |
boolean b2 = Boolean.parseBoolean(s2); | |
System.out.println(b2); |
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
public class IntToChar { | |
public static void main(String[] args) { | |
int kodi = 65; | |
char karakteri = (char) kodi; | |
System.out.println(karakteri); | |
} | |
} |
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
public class CharToInt { | |
public static void main(String[] args) { | |
char karakteri1 = 'a'; | |
int kodi1 = karakteri1; | |
System.out.println(kodi1); | |
char karakteri2 = 'A'; | |
int kodi2 = karakteri2; | |
System.out.println(kodi2); |