valueconverter

converting timestamp to date in java

岁酱吖の 提交于 2019-11-28 09:04:32
问题 This is my database: Here I have to check the query current date+status=Q information and get the count value. This is my code: public class TodayQ { public int data() { int count=0; Date date = new Date(timestamp); DateFormat dateFormat = new SimpleDateFormat ("yyyy-MM-dd"); System.out.println( dateFormat.format (date)); // count++; try { Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection( "jdbc:mysql://localhost:3306/pro", "root", ""); PreparedStatement

Convert binary string to binary or decimal value

孤街浪徒 提交于 2019-11-27 01:01:58
Is there any function to convert binary string into binary or decimal value? If I have a binary string 000101 , what should I do to convert it into 5 ? Here is what you can try: binStr <- "00000001001100110000010110110111" # 20121015 (binNum <- 00000001001100110000010110110111) # 20121015 [1] 1.0011e+24 binVec <- c(1,0,1,0,0,0,1,1,0,0,0,0,0,0,1,0,0,0,0,0,0,1) # 2670721 shortBin <- 10011010010 # 1234 BinToDec <- function(x) sum(2^(which(rev(unlist(strsplit(as.character(x), "")) == 1))-1)) BinToDec(binStr) [1] 20121015 BinToDec(binNum) [1] 576528 BinToDec(binVec) [1] 2670721 BinToDec(shortBin)