Skip to content

Commit 8a49ef9

Browse files
author
isayan
committed
fix Convert Date
1 parent 4e265e5 commit 8a49ef9

File tree

6 files changed

+55
-44
lines changed

6 files changed

+55
-44
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
netbeans.org-netbeans-modules-javascript2-requirejs.enabled=true
22
release_version_major=2.2
3-
release_version_minor=13.1
3+
release_version_minor=13.2
Binary file not shown.

release/YaguraExtender-v2.2.jar

134 Bytes
Binary file not shown.

src/main/java/yagura/view/JTransCoderTab.form

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2449,9 +2449,9 @@
24492449
<Component id="btnZoneDateCopy" min="-2" pref="90" max="-2" attributes="0"/>
24502450
<Component id="btnJavaSerialCopy" alignment="0" min="-2" pref="90" max="-2" attributes="0"/>
24512451
<Component id="btnExcelSerial" min="-2" pref="90" max="-2" attributes="0"/>
2452-
<Component id="cmbTimezone" min="-2" pref="153" max="-2" attributes="0"/>
2452+
<Component id="cmbTimezone" min="-2" pref="261" max="-2" attributes="0"/>
24532453
</Group>
2454-
<EmptySpace min="-2" pref="824" max="-2" attributes="0"/>
2454+
<EmptySpace min="-2" pref="716" max="-2" attributes="0"/>
24552455
</Group>
24562456
</Group>
24572457
</DimensionLayout>
@@ -2580,7 +2580,7 @@
25802580
<Component class="javax.swing.JFormattedTextField" name="txtExcelSerial">
25812581
<Properties>
25822582
<Property name="formatterFactory" type="javax.swing.JFormattedTextField$AbstractFormatterFactory" editor="org.netbeans.modules.form.editors.AbstractFormatterFactoryEditor">
2583-
<Format format="####.00" subtype="-1" type="0"/>
2583+
<Format format="####.000000" subtype="-1" type="0"/>
25842584
</Property>
25852585
<Property name="horizontalAlignment" type="int" value="11"/>
25862586
<Property name="toolTipText" type="java.lang.String" value=""/>

src/main/java/yagura/view/JTransCoderTab.java

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,19 @@ public class JTransCoderTab extends javax.swing.JPanel implements ITab {
7474
final PropertyChangeListener listener = new PropertyChangeListener() {
7575
@Override
7676
public void propertyChange(PropertyChangeEvent evt) {
77-
ThemeUI.changeStyleTheme(txtOutputRaw);
78-
ThemeUI.changeStyleTheme(txtOutputFormat);
77+
ThemeUI.changeStyleTheme(txtOutputRaw);
78+
ThemeUI.changeStyleTheme(txtOutputFormat);
7979
}
8080
};
81-
81+
8282
/**
8383
* Creates new form JTransCoder
8484
*/
8585
public JTransCoderTab() {
8686
initComponents();
8787
customizeComponents();
8888
this.listener.propertyChange(null);
89-
UIManager.addPropertyChangeListener(this.listener);
89+
UIManager.addPropertyChangeListener(this.listener);
9090
}
9191
private final QuickSearchTab quickSearchTabRaw = new QuickSearchTab();
9292
private final QuickSearchTab quickSearchTabFormat = new QuickSearchTab();
@@ -115,15 +115,15 @@ public JTransCoderTab() {
115115
private org.fife.ui.rsyntaxtextarea.RSyntaxTextArea txtOutputFormat;
116116

117117
private final static DateTimeFormatter GMT_DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy/MM/dd H:mm:ss zzz");
118-
118+
119119
private final static String [] SHORT_ZONEIDS = {
120-
"ACT", "AET", "AGT", "ART", "AST", "BET", "BST", "CAT", "CNT", "CST", "CTT", "EAT", "ECT", "IET", "IST", "JST", "MIT", "NET", "NST", "PLT", "PNT", "PRT", "PST", "SST", "VST", "EST", "MST", "HST"
120+
"GMT", "ACT", "AET", "AGT", "ART", "AST", "BET", "BST", "CAT", "CNT", "CST", "CTT", "EAT", "ECT", "IET", "IST", "JST", "MIT", "NET", "NST", "PLT", "PNT", "PRT", "PST", "SST", "VST", "EST", "MST", "HST"
121121
};
122122

123123
private final ViewStateDecoderTab viewStateDecoderTab = new ViewStateDecoderTab();
124124

125125
private final JWTTokenDecoderTab jwtTokenDecoderTab = new JWTTokenDecoderTab();
126-
126+
127127
private void customizeComponents() {
128128

129129
/**
@@ -217,12 +217,14 @@ public void setData(byte[] rawData) {
217217
* * UI design end **
218218
*/
219219

220+
220221
int tz_offset = 0;
221222
ZoneId systemZone = ZoneId.systemDefault();
222223
for (int i = 0; i < SHORT_ZONEIDS.length; i++) {
223-
ZoneId zone = ZoneId.of(ZoneId.SHORT_IDS.get(SHORT_ZONEIDS[i]));
224-
this.cmbTimezone.addItem(SHORT_ZONEIDS[i] + " - " + zone.getId());
225-
if (systemZone.equals(zone)) {
224+
ZoneId zoneId = ZoneId.of(SHORT_ZONEIDS[i], ZoneId.SHORT_IDS);
225+
String shortIDS = "GMT".equals(SHORT_ZONEIDS[i]) ? "Greenwich Mean Time" : ZoneId.SHORT_IDS.get(SHORT_ZONEIDS[i]);
226+
this.cmbTimezone.addItem(SHORT_ZONEIDS[i] + " - " + shortIDS + " (" + zoneId.getRules().getOffset(Instant.EPOCH) + ")");
227+
if (systemZone.equals(zoneId)) {
226228
tz_offset = i;
227229
}
228230
}
@@ -280,7 +282,7 @@ private void txtOutputRawCaretUpdate(javax.swing.event.CaretEvent evt) {
280282
private ZoneId getSelectZoneId() {
281283
int index = this.cmbTimezone.getSelectedIndex();
282284
if (0 <= index && index < SHORT_ZONEIDS.length) {
283-
return ZoneId.of(ZoneId.SHORT_IDS.get(SHORT_ZONEIDS[index]));
285+
return ZoneId.of(SHORT_ZONEIDS[index], ZoneId.SHORT_IDS);
284286
}
285287
else {
286288
return ZoneId.systemDefault();
@@ -2065,7 +2067,7 @@ public void itemStateChanged(java.awt.event.ItemEvent evt) {
20652067
}
20662068
});
20672069

2068-
txtExcelSerial.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("####.00"))));
2070+
txtExcelSerial.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("####.000000"))));
20692071
txtExcelSerial.setHorizontalAlignment(javax.swing.JTextField.TRAILING);
20702072
txtExcelSerial.setToolTipText("");
20712073
txtExcelSerial.setMinimumSize(new java.awt.Dimension(180, 22));
@@ -2140,8 +2142,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
21402142
.addComponent(btnZoneDateCopy, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
21412143
.addComponent(btnJavaSerialCopy, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
21422144
.addComponent(btnExcelSerial, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
2143-
.addComponent(cmbTimezone, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE))
2144-
.addGap(824, 824, 824))
2145+
.addComponent(cmbTimezone, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE))
2146+
.addGap(716, 716, 716))
21452147
);
21462148
tabDateConverterLayout.setVerticalGroup(
21472149
tabDateConverterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -2481,7 +2483,7 @@ private void btnEncodeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIR
24812483
}
24822484
}
24832485
encode = buff.toString();
2484-
} else if (this.rdoCLang.isSelected()) {
2486+
} else if (this.rdoCLang.isSelected()) {
24852487
encode = TransUtil.encodeCLangQuote(encode, metaChar);
24862488
} else if (this.rdoSQLLang.isSelected()) {
24872489
encode = TransUtil.encodeSQLLangQuote(encode, metaChar);
@@ -3178,7 +3180,6 @@ private void spnDatetimeStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-F
31783180
private void cmbTimezoneItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cmbTimezoneItemStateChanged
31793181
Date date = this.getConverterDateTime();
31803182
ZoneId zoneId = getSelectZoneId();
3181-
BurpExtender.errPrintln("ZoneId:" + zoneId);
31823183
ZonedDateTime zdtm = ZonedDateTime.ofInstant(date.toInstant(), zoneId);
31833184
this.txtZoneDate.setText(GMT_DATE_FORMATTER.format(zdtm));
31843185
}//GEN-LAST:event_cmbTimezoneItemStateChanged
@@ -3216,27 +3217,27 @@ private void btnHexIPActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRS
32163217
}//GEN-LAST:event_btnHexIPActionPerformed
32173218

32183219
private void btnDecIPConvertActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDecIPConvertActionPerformed
3219-
int dec1 = ConvertUtil.parseIntDefault(this.txtDec1.getText(), -1);
3220-
int dec2 = ConvertUtil.parseIntDefault(this.txtDec2.getText(), -1);
3221-
int dec3 = ConvertUtil.parseIntDefault(this.txtDec3.getText(), -1);
3220+
int dec1 = ConvertUtil.parseIntDefault(this.txtDec1.getText(), -1);
3221+
int dec2 = ConvertUtil.parseIntDefault(this.txtDec2.getText(), -1);
3222+
int dec3 = ConvertUtil.parseIntDefault(this.txtDec3.getText(), -1);
32223223
int dec4 = ConvertUtil.parseIntDefault(this.txtDec4.getText(), -1);
32233224
if (dec1 < 0 || dec2 < 0 || dec3 < 0 || dec4 < 0 ) {
32243225
this.lblIPValid.setText("IP addres Invalid");
32253226
return;
32263227
}
3227-
if (!(0 <= dec1 && dec1 <= 255 &&
3228-
0 <= dec2 && dec2 <= 255 &&
3229-
0 <= dec3 && dec3 <= 255 &&
3228+
if (!(0 <= dec1 && dec1 <= 255 &&
3229+
0 <= dec2 && dec2 <= 255 &&
3230+
0 <= dec3 && dec3 <= 255 &&
32303231
0 <= dec4 && dec4 <= 255)) {
32313232
this.lblIPValid.setText("IP addres renge Invalid");
32323233
return;
32333234
}
3234-
3235+
32353236
this.txtDotOctIP.setText(IpUtil.ipv4ToDotOct(dec1, dec2, dec3, dec4));
32363237
this.txtOctIP.setText(IpUtil.ipv4ToOct(dec1, dec2, dec3, dec4));
32373238
this.txtHexIP.setText(IpUtil.ipv4ToHex(dec1, dec2, dec3, dec4));
3238-
this.txtDotHexIP.setText(IpUtil.ipv4ToDotHex(dec1, dec2, dec3, dec4));
3239-
this.txtIntIP.setText(IpUtil.ipv4ToInt(dec1, dec2, dec3, dec4));
3239+
this.txtDotHexIP.setText(IpUtil.ipv4ToDotHex(dec1, dec2, dec3, dec4));
3240+
this.txtIntIP.setText(IpUtil.ipv4ToInt(dec1, dec2, dec3, dec4));
32403241
}//GEN-LAST:event_btnDecIPConvertActionPerformed
32413242

32423243
private void txtUnixtimeFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtUnixtimeFocusLost

src/test/java/extend/util/external/TransUtilTest.java

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static org.junit.Assert.*;
2020
import java.math.BigDecimal;
2121
import java.nio.charset.StandardCharsets;
22+
import java.time.Instant;
2223
import java.time.LocalDate;
2324
import java.time.LocalDateTime;
2425
import java.time.Month;
@@ -660,7 +661,7 @@ public void testStandardLangMeta() {
660661
assertEquals("a\\tb\\rc\\nd", TransUtil.encodeStandardLangMeta("a\tb\rc\nd"));
661662
assertEquals("a\\\\d", TransUtil.encodeStandardLangMeta("a\\\\d"));
662663
}
663-
664+
664665
/**
665666
* Test of encodeJsLangMeta,decodeJsLangMeta method, of class TransUtil.
666667
*/
@@ -718,7 +719,7 @@ public void testCLangQuote() {
718719
assertEquals("host", TransUtil.decodeCLangQuote("host", false));
719720
assertEquals("\\123\"456\\", TransUtil.decodeCLangQuote("\\\\123\\\"456\\\\", false));
720721
assertEquals("\\123'456\\", TransUtil.decodeCLangQuote("\\\\123'456\\\\", false));
721-
722+
722723
// metachar
723724
assertEquals("\\r\\nhost\\t", TransUtil.encodeCLangQuote("\r\nhost\t", true));
724725
assertEquals("ho\\\\st", TransUtil.encodeCLangQuote("ho\\st", true));
@@ -728,7 +729,7 @@ public void testCLangQuote() {
728729
assertEquals("\r\nhost\t", TransUtil.decodeCLangQuote("\\r\\nhost\\t", true));
729730
assertEquals("ho\\st", TransUtil.decodeCLangQuote("ho\\\\st", true));
730731
assertEquals("\\123\"456\\", TransUtil.decodeCLangQuote("\\\\123\\\"456\\\\", true));
731-
assertEquals("\\123'456\\", TransUtil.decodeCLangQuote("\\\\123'456\\\\", true));
732+
assertEquals("\\123'456\\", TransUtil.decodeCLangQuote("\\\\123'456\\\\", true));
732733
}
733734

734735
/**
@@ -745,12 +746,12 @@ public void testSQLLangQuote() {
745746
// metachar
746747
assertEquals("\\r\\nhost\\t", TransUtil.encodeSQLLangQuote("\r\nhost\t", true));
747748
assertEquals("ho\\st", TransUtil.encodeSQLLangQuote("ho\\st", true));
748-
assertEquals("\\\\123'456\\\\", TransUtil.decodeSQLangQuote("\\\\123''456\\\\", true));
749+
assertEquals("\\\\123'456\\\\", TransUtil.decodeSQLangQuote("\\\\123''456\\\\", true));
749750
assertEquals("\\123\"456\\", TransUtil.encodeSQLLangQuote("\\123\"456\\", true));
750751

751752
assertEquals("\r\nhost\t", TransUtil.decodeSQLangQuote("\\r\\nhost\\t", true));
752753
assertEquals("ho\\st", TransUtil.decodeSQLangQuote("ho\\st", true));
753-
assertEquals("\\\\123'456\\\\", TransUtil.decodeSQLangQuote("\\\\123''456\\\\", true));
754+
assertEquals("\\\\123'456\\\\", TransUtil.decodeSQLangQuote("\\\\123''456\\\\", true));
754755
assertEquals("\\123\"456\\", TransUtil.decodeSQLangQuote("\\123\"456\\", true));
755756
}
756757

@@ -957,32 +958,32 @@ public void testStringBuilder() {
957958
b.append((String)null);
958959
System.out.println("append:" + b.toString());
959960
}
960-
961+
961962
@Test
962963
public void testOrderdChar() {
963964
{
964965
char ord = TransUtil.getOrderdChar(0);
965-
assertEquals(ord, '0');
966+
assertEquals(ord, '0');
966967
}
967968
{
968969
char ord = TransUtil.getOrderdChar(10);
969-
assertEquals(ord, 'A');
970+
assertEquals(ord, 'A');
970971
}
971972
{
972973
char ord = TransUtil.getOrderdChar(9 + 26);
973-
assertEquals(ord, 'Z');
974+
assertEquals(ord, 'Z');
974975
}
975976
{
976977
char ord = TransUtil.getOrderdChar(10 + 26);
977-
assertEquals(ord, 'a');
978+
assertEquals(ord, 'a');
978979
}
979980
{
980981
char ord = TransUtil.getOrderdChar(9 + 26 + 26);
981-
assertEquals(ord, 'z');
982+
assertEquals(ord, 'z');
982983
}
983984
{
984985
char ord = TransUtil.getOrderdChar(10 + 26 + 26);
985-
assertEquals(ord, '0');
986+
assertEquals(ord, '0');
986987
}
987988
}
988989

@@ -999,7 +1000,16 @@ public void testDateTime() {
9991000
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd H:mm:ss zzz");
10001001
String s = formatter.format(zdtm);
10011002
System.out.println("testDateTime.format:" + s);
1002-
}
1003-
1004-
1003+
}
1004+
1005+
@Test
1006+
public void testZoneDateTime() {
1007+
System.out.println("testZoneDateTime");
1008+
ZoneId id = ZoneId.of("JST", ZoneId.SHORT_IDS);
1009+
System.out.println(id.getId());
1010+
System.out.println(id.getRules().getOffset(Instant.EPOCH));
1011+
System.out.println(id.getRules().toString());
1012+
}
1013+
1014+
10051015
}

0 commit comments

Comments
 (0)