use of java.text.Format in project j2objc by google.
the class TCKDateTimeFormatter method test_toFormat_format.
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
@Test
public void test_toFormat_format() throws Exception {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
Format format = test.toFormat();
String result = format.format(LocalDate.of(2008, 6, 30));
assertEquals(result, "ONE30");
}
use of java.text.Format in project j2objc by google.
the class TCKDateTimeFormatter method test_toFormat_parseObject_StringParsePosition_nullParsePosition.
@Test(expected = NullPointerException.class)
public void test_toFormat_parseObject_StringParsePosition_nullParsePosition() throws Exception {
// SimpleDateFormat has this behavior
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
Format format = test.toFormat();
format.parseObject("ONE30", (ParsePosition) null);
}
use of java.text.Format in project j2objc by google.
the class TCKDateTimeFormatter method test_toFormat_Query_format.
// -----------------------------------------------------------------------
@Test
public void test_toFormat_Query_format() throws Exception {
Format format = BASIC_FORMATTER.toFormat();
String result = format.format(LocalDate.of(2008, 6, 30));
assertEquals(result, "ONE30");
}
use of java.text.Format in project j2objc by google.
the class TCKDateTimeFormatter method test_toFormat_parseObject_StringParsePosition_parseError.
@Test
public void test_toFormat_parseObject_StringParsePosition_parseError() throws Exception {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
Format format = test.toFormat();
ParsePosition pos = new ParsePosition(0);
TemporalAccessor result = (TemporalAccessor) format.parseObject("ONEXXX", pos);
// TODO: is this right?
assertEquals(pos.getIndex(), 0);
assertEquals(pos.getErrorIndex(), 3);
assertEquals(result, null);
}
use of java.text.Format in project SAGU by brianmcmichael.
the class InventoryRequest method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == jbtInventoryRequest) {
SwingWorker<Object, Void> inventoryWorker = new SwingWorker<Object, Void>() {
@Override
protected Object doInBackground() throws Exception {
// Create dumb progressbar
Date d = new Date();
JFrame inventoryFrame = new JFrame("Waiting for inventory");
{
inventoryFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
Calendar cal = Calendar.getInstance();
cal.setTime(d);
cal.add(Calendar.MINUTE, 250);
String doneString = cal.getTime().toString();
JLabel doneTimeLabel = new JLabel("<html><body>Inventory of vault " + irVault + " requested.<br>Estimated completion by " + doneString + "</html></body>");
final JProgressBar dumJProgressBar = new JProgressBar(JProgressBar.HORIZONTAL);
dumJProgressBar.setIndeterminate(true);
inventoryFrame.add(dumJProgressBar, BorderLayout.NORTH);
inventoryFrame.add(doneTimeLabel, BorderLayout.CENTER);
inventoryFrame.setBackground(wc);
inventoryFrame.setSize(300, 60);
}
centerDefineFrame(inventoryFrame, 500, 100);
inventoryFrame.setVisible(true);
try {
JobParameters jParameters = new JobParameters().withType("inventory-retrieval");
InitiateJobRequest initJobRequest = new InitiateJobRequest().withVaultName(irVault).withJobParameters(jParameters);
InitiateJobResult initJobResult = irClient.initiateJob(initJobRequest);
String thisJobId = initJobResult.getJobId();
Thread.sleep(12600000);
Boolean success = waitForJob(irClient, irVault, thisJobId);
while (!success) {
Thread.sleep(WAIT_TIME);
success = waitForJob(irClient, irVault, thisJobId);
}
GetJobOutputRequest gjoRequest = new GetJobOutputRequest().withVaultName(irVault).withJobId(thisJobId);
GetJobOutputResult gjoResult = irClient.getJobOutput(gjoRequest);
Format formatter = new SimpleDateFormat("yyyyMMMdd_HHmmss");
String fileDate = formatter.format(d);
String fileName = irVault + fileDate + ".txt";
String filePath = "" + CUR_DIR + System.getProperty("file.separator") + fileName;
FileWriter fileStream = new FileWriter(filePath);
BufferedWriter out = new BufferedWriter(fileStream);
BufferedReader in = new BufferedReader(new InputStreamReader(gjoResult.getBody()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
out.write(inputLine);
}
out.close();
inventoryFrame.setVisible(false);
JOptionPane.showMessageDialog(null, "Successfully exported " + irVault + " inventory to " + filePath.toString(), "Saved", JOptionPane.INFORMATION_MESSAGE);
return null;
} catch (AmazonServiceException k) {
JOptionPane.showMessageDialog(null, "The server returned an error. Files will not be inventoried for 24 hours after upload. Also check that correct location of vault has been set on the previous page.", "Error", JOptionPane.ERROR_MESSAGE);
System.out.println("" + k);
inventoryFrame.setVisible(false);
} catch (AmazonClientException i) {
JOptionPane.showMessageDialog(null, "Client Error. Check that all fields are correct. Inventory not requested.", "Error", JOptionPane.ERROR_MESSAGE);
inventoryFrame.setVisible(false);
} catch (Exception j) {
JOptionPane.showMessageDialog(null, "Inventory not found. Unspecified Error.", "Error", JOptionPane.ERROR_MESSAGE);
inventoryFrame.setVisible(false);
}
return null;
}
};
inventoryWorker.execute();
try {
Thread.sleep(500);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
this.setVisible(false);
dispose();
} else if (e.getSource() == jbtBack) {
this.setVisible(false);
dispose();
} else {
JOptionPane.showMessageDialog(this, "Please choose a valid action.");
}
}
Aggregations