1.myeclipse 2015 stable 1.0 è¿ä¸äºmarketplace
2.关于java中DecimalFormat的问题。
3.JAVAå®ç°è®¡ç®å¨åè½
myeclipse 2015 stable 1.0 è¿ä¸äºmarketplace
çæMyEclipse8.5注åç çjavaæºç çæMyEclipse8.5注åç çjavaæºç MyEclipseKeyGen MyEclipse8.5注åæº MyEclipse8.5注åç çæ MyEclipse8.5注åæºæºç
[java] view plaincopyprint?源码分析pdf
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class MyEclipseKeyGen {
private static final String LL = "Decompiling this copyrighted software is a violation of both your license agreement and the Digital Millenium Copyright Act of (http://www.loc.gov/copyright/legislation/dmca.pdf). Under section of the DMCA, penalties range up to a $, fine or up to five years imprisonment for a first offense. Think about it; pay for a license, avoid prosecution, and feel better about yourself.";
public String getSerial(String userId, String licenseNum) {
java.util.Calendar cal = java.util.Calendar.getInstance();
cal.add(1, 3);
cal.add(6, -1);
java.text.NumberFormat nf = new java.text.DecimalFormat("");
licenseNum = nf.format(Integer.valueOf(licenseNum));
String verTime = new StringBuilder("-").append(
new java.text.SimpleDateFormat("yyMMdd").format(cal.getTime()))
.append("0").toString();
String type = "YE3MP-";
String need = new StringBuilder(userId.substring(0, 1)).append(type)
.append("").append(licenseNum).append(verTime).toString();
String dx = new StringBuilder(need).append(LL).append(userId)
.toString();
int suf = this.decode(dx);
String code = new StringBuilder(need).append(String.valueOf(suf))
.toString();
return this.change(code);
}
private int decode(String s) {
int i;
char[] ac;
int j;
int k;
i = 0;
ac = s.toCharArray();
j = 0;
k = ac.length;
while (j < k) {
i = ( * i) + ac[j];
j++;
}
return Math.abs(i);
}
private String change(String s) {
byte[] abyte0;
char[] ac;
int i;
int k;
int j;
abyte0 = s.getBytes();
ac = new char[s.length()];
i = 0;
k = abyte0.length;
while (i < k) {
j = abyte0[i];
if ((j >= ) && (j <= )) {
j = (((j - ) + 5) % ) + ;
} else if ((j >= ) && (j <= )) {
j = (((j - ) + ) % ) + ;
} else if ((j >= ) && (j <= )) {
j = (((j - ) + ) % ) + ;
}
ac[i] = (char) j;
i++;
}
return String.valueOf(ac);
}
public MyEclipseKeyGen() {
super();
}
public static void main(String[] args) {
try {
System.out.println("please input register name:");
BufferedReader reader = new BufferedReader(new InputStreamReader(
System.in));
String userId = null;
userId = reader.readLine();
MyEclipseKeyGen myeclipsekeygen = new MyEclipseKeyGen();
String res = myeclipsekeygen.getSerial(userId, "5");
System.out.println("Serial:" + res);
reader.readLine();
} catch (IOException ex) {
}
}
}
关于java中DecimalFormat的问题。
把newSalary转为double型,现手源码然后再format就好了,2017换肤源码看源码就会知道,办公自动源码String类型是分秒交易源码不被允许的public final StringBuffer format(Object number,StringBuffer toAppendTo,
FieldPosition pos) {
if (number instanceof Long || number instanceof Integer ||
number instanceof Short || number instanceof Byte ||
number instanceof AtomicInteger ||
number instanceof AtomicLong ||
(number instanceof BigInteger &&
((BigInteger)number).bitLength () < )) {
return format(((Number)number).longValue(), toAppendTo, pos);
} else if (number instanceof BigDecimal) {
return format((BigDecimal)number, toAppendTo, pos);
} else if (number instanceof BigInteger) {
return format((BigInteger)number, toAppendTo, pos);
} else if (number instanceof Number) {
return format(((Number)number).doubleValue(), toAppendTo, pos);
} else {
throw new IllegalArgumentException("Cannot format given Object as a Number");
}
}
JAVAå®ç°è®¡ç®å¨åè½
çå¥åç
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.text.DecimalFormat;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class Calculator {
//计ç®å¨é¢æ¿
private JFrame f = new JFrame("Calculator");
//è¾å ¥é¢æ³
private JPanel inputPanel = new JPanel();
//å åä¹é¤é¢æ¿
private JPanel operationPanel = new JPanel();
//æ°åé¢æ¿
private JPanel buttonsPanel = new JPanel();
//è¾å ¥æ°æ®ææ¬æ¡
private JTextField input = new JTextField();
//éæ ¼é®
private JButton backspace = new JButton("BackSpace");
//æ¸ ç©º
private JButton CE = new JButton("CE ");
//å é¤
private JButton C = new JButton("C ");
//ååè¿ç®ç¬¦å·é®
private JButton add = new JButton("+");
private JButton sub = new JButton("-");
private JButton mul = new JButton("*");
private JButton div = new JButton("/");
//å°æ°ç¹
private JButton decimal = new JButton(".");
//çå·
private JButton equal = new JButton("=");
//æ°åé®
private JButton zero = new JButton("0");
private JButton one = new JButton("1");
private JButton two = new JButton("2");
private JButton three = new JButton("3");
private JButton four = new JButton("4");
private JButton five = new JButton("5");
private JButton six = new JButton("6");
private JButton seven = new JButton("7");
private JButton eight = new JButton("8");
private JButton nine = new JButton("9");
private String num1 = "";//ä¿å第ä¸ä¸ªè¿ç®æ°å
private String operator = "";//ä¿åè¿ç®ç¬¦å·
public static void main(String[] args) {
new Calculator();//new计ç®å¨å®ä¾
}
public Calculator(){
//æ·»å ç»ä»¶ï¼å¸å±
inputPanel.add(input);
f.add(inputPanel, BorderLayout.NORTH);
operationPanel.add(backspace);
operationPanel.add(CE);
operationPanel.add(C);
f.add(operationPanel, BorderLayout.CENTER);
buttonsPanel.add(add);
buttonsPanel.add(sub);
buttonsPanel.add(mul);
buttonsPanel.add(div);
buttonsPanel.add(one);
buttonsPanel.add(two);
buttonsPanel.add(three);
buttonsPanel.add(zero);
buttonsPanel.add(four);
buttonsPanel.add(five);
buttonsPanel.add(six);
buttonsPanel.add(decimal);
buttonsPanel.add(seven);
buttonsPanel.add(eight);
buttonsPanel.add(nine);
buttonsPanel.add(equal);
buttonsPanel.setLayout(new GridLayout(4, 4));
f.add(buttonsPanel, BorderLayout.SOUTH);
//注åå个ç»ä»¶çå¬äºä»¶
backspace.addMouseListener(new OperationMouseListener());
CE.addMouseListener(new OperationMouseListener());
C.addMouseListener(new OperationMouseListener());
decimal.addMouseListener(new OperationMouseListener());
equal.addMouseListener(new OperationMouseListener());
//注åååè¿ç®çå¬
add.addMouseListener(new CalcMouseListener());
sub.addMouseListener(new CalcMouseListener());
mul.addMouseListener(new CalcMouseListener());
div.addMouseListener(new CalcMouseListener());
//注åæ°åçå¬äºä»¶
zero.addMouseListener(new NumberMouseListener());
one.addMouseListener(new NumberMouseListener());
two.addMouseListener(new NumberMouseListener());
three.addMouseListener(new NumberMouseListener());
four.addMouseListener(new NumberMouseListener());
five.addMouseListener(new NumberMouseListener());
six.addMouseListener(new NumberMouseListener());
seven.addMouseListener(new NumberMouseListener());
eight.addMouseListener(new NumberMouseListener());
nine.addMouseListener(new NumberMouseListener());
f.setVisible(true);
f.pack();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
private class NumberMouseListener implements MouseListener{
public void mouseClicked(MouseEvent e) {
if(input.getText().trim().equals("0")){ //å¦æææ¬æ¡å·²ç»æ¯0ï¼ç»æè¿æ¯0
input.setText(((JButton)e.getSource()).getText().trim());
}else{ //å¦åçè¯ï¼æ0æ·»å å°åé¢ï¼è¬å¦ææ¬æ¡æ¯1ï¼ç»æ就为
input.setText(input.getText().concat(((JButton)e.getSource()).getText().trim()));
}
}
public void mouseEntered(MouseEvent e) { }
public void mouseExited(MouseEvent e) { }
public void mousePressed(MouseEvent e) { }
public void mouseReleased(MouseEvent e) { }
}
private class CalcMouseListener implements MouseListener{
//å¦æè¾å ¥çæ¯è¿ç®ç¬¦å·ï¼ä¿å第ä¸ä¸ªç»æåè¿ç®ç¬¦å·
public void mouseClicked(MouseEvent e) {
num1 = input.getText().trim();input.setText("");
operator = ((JButton)e.getSource()).getText().trim();
}
public void mouseEntered(MouseEvent e) { }
public void mouseExited(MouseEvent e) { }
public void mousePressed(MouseEvent e) { }
public void mouseReleased(MouseEvent e) { }
}
private class OperationMouseListener implements MouseListener{
public void mouseClicked(MouseEvent e) {
if(e.getSource() == backspace){ //éæ ¼é®ï¼å é¤ä¸ä¸ªç´å°æ²¡æå符å é¤
String inputText = input.getText();
if(inputText.length() > 0){
input.setText(inputText.substring(0, inputText.length() - 1));
}
}else if(e.getSource() == C){
input.setText("0");//Cï¼æ¸ 空ææè¿ç®æ°åå符å·
num1 = "";
}else if(e.getSource() == CE){
input.setText("0");//CE-->å°ææ¬æ¡ç½®ä¸º0
}else if(e.getSource() == decimal){
String text = input.getText().trim();
//å¦ææäºå°æ°ç¹ï¼å¦æææ¬æ¡å·²ç»æå°æ°ç¹ï¼ä¸åä»»ä½æä½ï¼å¦åå¨ç»æåé¢å ä¸å°æ°ç¹
if(text.indexOf(".") == -1){
input.setText(text.concat("."));
}
}else if(e.getSource() == equal){
//å¦ææ¯çå·
if(!operator.trim().equals("")){
if(!input.getText().trim().equals("")){
double result = 0D;
if(operator.equals("+")){ //æ§è¡å æ³è¿ç®
result = Double.parseDouble(num1) + Double.parseDouble(input.getText().trim());
}else if(operator.equals("-")){ //åæ³è¿ç®
result = Double.parseDouble(num1) - Double.parseDouble(input.getText().trim());
}else if(operator.equals("*")){ //ä¹æ³è¿ç®
result = Double.parseDouble(num1) * Double.parseDouble(input.getText().trim());
}else if(operator.equals("/")){ //é¤æ³è¿ç®
result = Double.parseDouble(num1) / Double.parseDouble(input.getText().trim());
}
//æ ¼å¼åæç»ç»æï¼ä¿ç两ä½å°æ°ç¹
input.setText(new DecimalFormat("0.").format(result));
}
}
}
}
public void mouseEntered(MouseEvent e) { }
public void mouseExited(MouseEvent e) { }
public void mousePressed(MouseEvent e) { }
public void mouseReleased(MouseEvent e) { }
}
}