WeixiangYan/CodeTransOcean huggingface dataset:
Task: Polymorphic copy






PHP: <?php
class T {
      function name() { return "T"; }
}

class S {
      function name() { return "S"; }
}

$obj1 = new T();
$obj2 = new S();
$obj3 = clone $obj1;
$obj4 = clone $obj2;
echo $obj3->name(), "\n"; // prints "T"
echo $obj4->name(), "\n"; // prints "S"
?>






Ada: with Ada.Text_IO;  use Ada.Text_IO;

procedure Test_Polymorphic_Copy is
   package Base is
      type T is tagged null record;
      type T_ptr is access all T'Class;
      function Name (X : T) return String;
   end Base;
   use Base;
   
   package body Base is
      function Name (X : T) return String is
      begin
         return "T";
      end Name;
   end Base;
   
      
   procedure Copier (X : T'Class) is
      Duplicate : T'Class := X;  
   begin
      Put_Line ("Copied " & Duplicate.Name); 
   end Copier;

      
   function Clone (X : T'Class) return T_ptr is
   begin
      return new T'Class(X);
   end Copier;

   package Derived is   
      type S is new T with null record;
      overriding function Name (X : S) return String;
   end Derived;
   use Derived;
   
   package body Derived is   
      function Name (X : S) return String is
      begin
         return "S";
      end Name;
   end Derived;

   Object_1 : T;
   Object_2 : S;
   Object_3 : T_ptr := Clone(T);
   Object_4 : T_ptr := Clone(S);
begin
   Copier (Object_1);
   Copier (Object_2);
   Put_Line ("Cloned " & Object_3.all.Name);
   Put_Line ("Cloned " & Object_4.all.Name);
end Test_Polymorphic_Copy;
Task: Polymorphic copy






PHP: <?php
class T {
      function name() { return "T"; }
}

class S {
      function name() { return "S"; }
}

$obj1 = new T();
$obj2 = new S();
$obj3 = clone $obj1;
$obj4 = clone $obj2;
echo $obj3->name(), "\n"; // prints "T"
echo $obj4->name(), "\n"; // prints "S"
?>
Task: User input_Text



C#: using System;

namespace C_Sharp_Console {

    class example {

        static void Main() {
            string word;
            int num;
            
            Console.Write("Enter an integer: ");
            num = Console.Read();
            Console.Write("Enter a String: ");
            word = Console.ReadLine();
        }
    }
}









Ada: function Get_String return String is
  Line : String (1 .. 1_000);
  Last : Natural;
begin
  Get_Line (Line, Last);
  return Line (1 .. Last);
end Get_String;

function Get_Integer return Integer is
  S : constant String := Get_String;
begin
  return Integer'Value (S);
  
end Get_Integer;
Task: User input_Text

C: #include <stdio.h>
#include <stdlib.h>

int main(void)
{
    
    char str[BUFSIZ];
    puts("Enter a string: ");
    fgets(str, sizeof(str), stdin);

    
    long num;
    char buf[BUFSIZ];
    do
    {
        puts("Enter 75000: ");
        fgets(buf, sizeof(buf), stdin);
        num = strtol(buf, NULL, 10);
    } while (num != 75000);

    return EXIT_SUCCESS;
}











Ada: function Get_String return String is
  Line : String (1 .. 1_000);
  Last : Natural;
begin
  Get_Line (Line, Last);
  return Line (1 .. Last);
end Get_String;

function Get_Integer return Integer is
  S : constant String := Get_String;
begin
  return Integer'Value (S);
  
end Get_Integer;
Task: User input_Text


C++: #include <iostream>
#include <string>
using namespace std;

int main()
{
     
     
     long int integer_input;
     string string_input;
     cout << "Enter an integer:  ";
     cin >> integer_input;
     cout << "Enter a string:  ";
     cin >> string_input;
     return 0;
}










Ada: function Get_String return String is
  Line : String (1 .. 1_000);
  Last : Natural;
begin
  Get_Line (Line, Last);
  return Line (1 .. Last);
end Get_String;

function Get_Integer return Integer is
  S : constant String := Get_String;
begin
  return Integer'Value (S);
  
end Get_Integer;
Task: User input_Text




Go: package main

import "fmt"

func main() {
    var s string
    var i int
    if _, err := fmt.Scan(&s, &i); err == nil && i == 75000 {
        fmt.Println("good")
    } else {
        fmt.Println("wrong")
    }
}








Ada: function Get_String return String is
  Line : String (1 .. 1_000);
  Last : Natural;
begin
  Get_Line (Line, Last);
  return Line (1 .. Last);
end Get_String;

function Get_Integer return Integer is
  S : constant String := Get_String;
begin
  return Integer'Value (S);
  
end Get_Integer;
Task: User input_Text





Java: import java.util.Scanner;

public class GetInput {
    public static void main(String[] args) throws Exception {
        Scanner s = new Scanner(System.in);
        System.out.print("Enter a string: ");
        String str = s.nextLine();
        System.out.print("Enter an integer: ");
        int i = Integer.parseInt(s.next());
    }
}







Ada: function Get_String return String is
  Line : String (1 .. 1_000);
  Last : Natural;
begin
  Get_Line (Line, Last);
  return Line (1 .. Last);
end Get_String;

function Get_Integer return Integer is
  S : constant String := Get_String;
begin
  return Integer'Value (S);
  
end Get_Integer;
Task: User input_Text







Python:    string = raw_input("Input a string: ")





Ada: function Get_String return String is
  Line : String (1 .. 1_000);
  Last : Natural;
begin
  Get_Line (Line, Last);
  return Line (1 .. Last);
end Get_String;

function Get_Integer return Integer is
  S : constant String := Get_String;
begin
  return Integer'Value (S);
  
end Get_Integer;
Task: User input_Text








VB: Public Sub text()
    Debug.Print InputBox("Input a string")
    Debug.Print InputBox("Input the integer 75000", "Input an integer", 75000, Context = "Long")
End Sub




Ada: function Get_String return String is
  Line : String (1 .. 1_000);
  Last : Natural;
begin
  Get_Line (Line, Last);
  return Line (1 .. Last);
end Get_String;

function Get_Integer return Integer is
  S : constant String := Get_String;
begin
  return Integer'Value (S);
  
end Get_Integer;
Task: User input_Text

C: #include <stdio.h>
#include <stdlib.h>

int main(void)
{
    
    char str[BUFSIZ];
    puts("Enter a string: ");
    fgets(str, sizeof(str), stdin);

    
    long num;
    char buf[BUFSIZ];
    do
    {
        puts("Enter 75000: ");
        fgets(buf, sizeof(buf), stdin);
        num = strtol(buf, NULL, 10);
    } while (num != 75000);

    return EXIT_SUCCESS;
}
Task: User input_Text



C#: using System;

namespace C_Sharp_Console {

    class example {

        static void Main() {
            string word;
            int num;
            
            Console.Write("Enter an integer: ");
            num = Console.Read();
            Console.Write("Enter a String: ");
            word = Console.ReadLine();
        }
    }
}
Task: User input_Text


C++: #include <iostream>
#include <string>
using namespace std;

int main()
{
     
     
     long int integer_input;
     string string_input;
     cout << "Enter an integer:  ";
     cin >> integer_input;
     cout << "Enter a string:  ";
     cin >> string_input;
     return 0;
}
Task: User input_Text





Java: import java.util.Scanner;

public class GetInput {
    public static void main(String[] args) throws Exception {
        Scanner s = new Scanner(System.in);
        System.out.print("Enter a string: ");
        String str = s.nextLine();
        System.out.print("Enter an integer: ");
        int i = Integer.parseInt(s.next());
    }
}
Task: User input_Text







Python:    string = raw_input("Input a string: ")
Task: User input_Text








VB: Public Sub text()
    Debug.Print InputBox("Input a string")
    Debug.Print InputBox("Input the integer 75000", "Input an integer", 75000, Context = "Long")
End Sub
Task: User input_Text




Go: package main

import "fmt"

func main() {
    var s string
    var i int
    if _, err := fmt.Scan(&s, &i); err == nil && i == 75000 {
        fmt.Println("good")
    } else {
        fmt.Println("wrong")
    }
}
Task: User input_Text



C#: using System;

namespace C_Sharp_Console {

    class example {

        static void Main() {
            string word;
            int num;
            
            Console.Write("Enter an integer: ");
            num = Console.Read();
            Console.Write("Enter a String: ");
            word = Console.ReadLine();
        }
    }
}








Fortran: character(20) :: s
integer :: i

print*, "Enter a string (max 20 characters)"
read*, s
print*, "Enter the integer 75000"
read*, i
Task: User input_Text


C++: #include <iostream>
#include <string>
using namespace std;

int main()
{
     
     
     long int integer_input;
     string string_input;
     cout << "Enter an integer:  ";
     cin >> integer_input;
     cout << "Enter a string:  ";
     cin >> string_input;
     return 0;
}









Fortran: character(20) :: s
integer :: i

print*, "Enter a string (max 20 characters)"
read*, s
print*, "Enter the integer 75000"
read*, i
Task: User input_Text

C: #include <stdio.h>
#include <stdlib.h>

int main(void)
{
    
    char str[BUFSIZ];
    puts("Enter a string: ");
    fgets(str, sizeof(str), stdin);

    
    long num;
    char buf[BUFSIZ];
    do
    {
        puts("Enter 75000: ");
        fgets(buf, sizeof(buf), stdin);
        num = strtol(buf, NULL, 10);
    } while (num != 75000);

    return EXIT_SUCCESS;
}










Fortran: character(20) :: s
integer :: i

print*, "Enter a string (max 20 characters)"
read*, s
print*, "Enter the integer 75000"
read*, i
Task: User input_Text





Java: import java.util.Scanner;

public class GetInput {
    public static void main(String[] args) throws Exception {
        Scanner s = new Scanner(System.in);
        System.out.print("Enter a string: ");
        String str = s.nextLine();
        System.out.print("Enter an integer: ");
        int i = Integer.parseInt(s.next());
    }
}






Fortran: character(20) :: s
integer :: i

print*, "Enter a string (max 20 characters)"
read*, s
print*, "Enter the integer 75000"
read*, i
Task: User input_Text







Python:    string = raw_input("Input a string: ")




Fortran: character(20) :: s
integer :: i

print*, "Enter a string (max 20 characters)"
read*, s
print*, "Enter the integer 75000"
read*, i
Task: User input_Text








VB: Public Sub text()
    Debug.Print InputBox("Input a string")
    Debug.Print InputBox("Input the integer 75000", "Input an integer", 75000, Context = "Long")
End Sub



Fortran: character(20) :: s
integer :: i

print*, "Enter a string (max 20 characters)"
read*, s
print*, "Enter the integer 75000"
read*, i
Task: User input_Text






PHP: #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);





Fortran: character(20) :: s
integer :: i

print*, "Enter a string (max 20 characters)"
read*, s
print*, "Enter the integer 75000"
read*, i
Task: User input_Text

C: #include <stdio.h>
#include <stdlib.h>

int main(void)
{
    
    char str[BUFSIZ];
    puts("Enter a string: ");
    fgets(str, sizeof(str), stdin);

    
    long num;
    char buf[BUFSIZ];
    do
    {
        puts("Enter 75000: ");
        fgets(buf, sizeof(buf), stdin);
        num = strtol(buf, NULL, 10);
    } while (num != 75000);

    return EXIT_SUCCESS;
}









COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Get-Input.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  Input-String PIC X(30).
       01  Input-Int    PIC 9(5).

       PROCEDURE DIVISION.
       DISPLAY "Enter a string:"
       ACCEPT Input-String

       DISPLAY "Enter a number:"
       ACCEPT Input-Int

       GOBACK
       .
Task: User input_Text



C#: using System;

namespace C_Sharp_Console {

    class example {

        static void Main() {
            string word;
            int num;
            
            Console.Write("Enter an integer: ");
            num = Console.Read();
            Console.Write("Enter a String: ");
            word = Console.ReadLine();
        }
    }
}







COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Get-Input.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  Input-String PIC X(30).
       01  Input-Int    PIC 9(5).

       PROCEDURE DIVISION.
       DISPLAY "Enter a string:"
       ACCEPT Input-String

       DISPLAY "Enter a number:"
       ACCEPT Input-Int

       GOBACK
       .
Task: User input_Text


C++: #include <iostream>
#include <string>
using namespace std;

int main()
{
     
     
     long int integer_input;
     string string_input;
     cout << "Enter an integer:  ";
     cin >> integer_input;
     cout << "Enter a string:  ";
     cin >> string_input;
     return 0;
}








COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Get-Input.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  Input-String PIC X(30).
       01  Input-Int    PIC 9(5).

       PROCEDURE DIVISION.
       DISPLAY "Enter a string:"
       ACCEPT Input-String

       DISPLAY "Enter a number:"
       ACCEPT Input-Int

       GOBACK
       .
Task: User input_Text





Java: import java.util.Scanner;

public class GetInput {
    public static void main(String[] args) throws Exception {
        Scanner s = new Scanner(System.in);
        System.out.print("Enter a string: ");
        String str = s.nextLine();
        System.out.print("Enter an integer: ");
        int i = Integer.parseInt(s.next());
    }
}





COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Get-Input.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  Input-String PIC X(30).
       01  Input-Int    PIC 9(5).

       PROCEDURE DIVISION.
       DISPLAY "Enter a string:"
       ACCEPT Input-String

       DISPLAY "Enter a number:"
       ACCEPT Input-Int

       GOBACK
       .
Task: User input_Text







Python:    string = raw_input("Input a string: ")



COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Get-Input.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  Input-String PIC X(30).
       01  Input-Int    PIC 9(5).

       PROCEDURE DIVISION.
       DISPLAY "Enter a string:"
       ACCEPT Input-String

       DISPLAY "Enter a number:"
       ACCEPT Input-Int

       GOBACK
       .
Task: User input_Text








VB: Public Sub text()
    Debug.Print InputBox("Input a string")
    Debug.Print InputBox("Input the integer 75000", "Input an integer", 75000, Context = "Long")
End Sub


COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Get-Input.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  Input-String PIC X(30).
       01  Input-Int    PIC 9(5).

       PROCEDURE DIVISION.
       DISPLAY "Enter a string:"
       ACCEPT Input-String

       DISPLAY "Enter a number:"
       ACCEPT Input-Int

       GOBACK
       .
Task: User input_Text




Go: package main

import "fmt"

func main() {
    var s string
    var i int
    if _, err := fmt.Scan(&s, &i); err == nil && i == 75000 {
        fmt.Println("good")
    } else {
        fmt.Println("wrong")
    }
}






COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Get-Input.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  Input-String PIC X(30).
       01  Input-Int    PIC 9(5).

       PROCEDURE DIVISION.
       DISPLAY "Enter a string:"
       ACCEPT Input-String

       DISPLAY "Enter a number:"
       ACCEPT Input-Int

       GOBACK
       .
Task: User input_Text






PHP: #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
Task: User input_Text






PHP: #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);






Ada: function Get_String return String is
  Line : String (1 .. 1_000);
  Last : Natural;
begin
  Get_Line (Line, Last);
  return Line (1 .. Last);
end Get_String;

function Get_Integer return Integer is
  S : constant String := Get_String;
begin
  return Integer'Value (S);
  
end Get_Integer;
Task: User input_Text






PHP: #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);




COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Get-Input.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  Input-String PIC X(30).
       01  Input-Int    PIC 9(5).

       PROCEDURE DIVISION.
       DISPLAY "Enter a string:"
       ACCEPT Input-String

       DISPLAY "Enter a number:"
       ACCEPT Input-Int

       GOBACK
       .
Task: Show the epoch



C#: using System;

class Program
{
    static void Main()
    {
        Console.WriteLine(new DateTime());
    }
}









Ada: with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Calendar.Conversions; use Ada.Calendar.Conversions;
procedure ShowEpoch is
   etime : Time := To_Ada_Time (0);
begin
   Put_Line (Image (Date => etime));
end ShowEpoch;
Task: Show the epoch

C: #include <time.h>
#include <stdio.h>

int main() {
    time_t t = 0;
    printf("%s", asctime(gmtime(&t)));
    return 0;
}











Ada: with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Calendar.Conversions; use Ada.Calendar.Conversions;
procedure ShowEpoch is
   etime : Time := To_Ada_Time (0);
begin
   Put_Line (Image (Date => etime));
end ShowEpoch;
Task: Show the epoch


C++: #include <iostream>
#include <chrono>
#include <ctime>
int main()
{
    std::chrono::system_clock::time_point epoch;
    std::time_t t = std::chrono::system_clock::to_time_t(epoch);
    std::cout << std::asctime(std::gmtime(&t)) << '\n';
    return 0;
}










Ada: with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Calendar.Conversions; use Ada.Calendar.Conversions;
procedure ShowEpoch is
   etime : Time := To_Ada_Time (0);
begin
   Put_Line (Image (Date => etime));
end ShowEpoch;
Task: Show the epoch




Go: package main
import ("fmt"; "time")

func main() {
    fmt.Println(time.Time{})
}








Ada: with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Calendar.Conversions; use Ada.Calendar.Conversions;
procedure ShowEpoch is
   etime : Time := To_Ada_Time (0);
begin
   Put_Line (Image (Date => etime));
end ShowEpoch;
Task: Show the epoch





Java: import java.text.DateFormat;
import java.util.Date;
import java.util.TimeZone;

public class DateTest{
    public static void main(String[] args) {
        Date date = new Date(0);
        DateFormat format = DateFormat.getDateTimeInstance();
        format.setTimeZone(TimeZone.getTimeZone("UTC"));
        System.out.println(format.format(date));
    }
}







Ada: with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Calendar.Conversions; use Ada.Calendar.Conversions;
procedure ShowEpoch is
   etime : Time := To_Ada_Time (0);
begin
   Put_Line (Image (Date => etime));
end ShowEpoch;
Task: Show the epoch







Python: >>> import time
>>> time.asctime(time.gmtime(0))
'Thu Jan  1 00:00:00 1970'
>>>





Ada: with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Calendar.Conversions; use Ada.Calendar.Conversions;
procedure ShowEpoch is
   etime : Time := To_Ada_Time (0);
begin
   Put_Line (Image (Date => etime));
end ShowEpoch;
Task: Show the epoch








VB: Sub Main()
    Debug.Print Format(0, "dd mmm yyyy hh:mm")
End Sub




Ada: with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Calendar.Conversions; use Ada.Calendar.Conversions;
procedure ShowEpoch is
   etime : Time := To_Ada_Time (0);
begin
   Put_Line (Image (Date => etime));
end ShowEpoch;
Task: Show the epoch

C: #include <time.h>
#include <stdio.h>

int main() {
    time_t t = 0;
    printf("%s", asctime(gmtime(&t)));
    return 0;
}
Task: Show the epoch



C#: using System;

class Program
{
    static void Main()
    {
        Console.WriteLine(new DateTime());
    }
}
Task: Show the epoch


C++: #include <iostream>
#include <chrono>
#include <ctime>
int main()
{
    std::chrono::system_clock::time_point epoch;
    std::time_t t = std::chrono::system_clock::to_time_t(epoch);
    std::cout << std::asctime(std::gmtime(&t)) << '\n';
    return 0;
}
Task: Show the epoch





Java: import java.text.DateFormat;
import java.util.Date;
import java.util.TimeZone;

public class DateTest{
    public static void main(String[] args) {
        Date date = new Date(0);
        DateFormat format = DateFormat.getDateTimeInstance();
        format.setTimeZone(TimeZone.getTimeZone("UTC"));
        System.out.println(format.format(date));
    }
}
Task: Show the epoch







Python: >>> import time
>>> time.asctime(time.gmtime(0))
'Thu Jan  1 00:00:00 1970'
>>>
Task: Show the epoch








VB: Sub Main()
    Debug.Print Format(0, "dd mmm yyyy hh:mm")
End Sub
Task: Show the epoch




Go: package main
import ("fmt"; "time")

func main() {
    fmt.Println(time.Time{})
}
Task: Show the epoch

C: #include <time.h>
#include <stdio.h>

int main() {
    time_t t = 0;
    printf("%s", asctime(gmtime(&t)));
    return 0;
}









COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. epoch.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  epoch-date.
           03  year                PIC 9(4).
           03  month               PIC 99.
           03  dday                PIC 99.

       PROCEDURE DIVISION.
           MOVE FUNCTION DATE-OF-INTEGER(1) TO epoch-date

           DISPLAY year "-" month "-" dday

           GOBACK
           .
Task: Show the epoch



C#: using System;

class Program
{
    static void Main()
    {
        Console.WriteLine(new DateTime());
    }
}







COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. epoch.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  epoch-date.
           03  year                PIC 9(4).
           03  month               PIC 99.
           03  dday                PIC 99.

       PROCEDURE DIVISION.
           MOVE FUNCTION DATE-OF-INTEGER(1) TO epoch-date

           DISPLAY year "-" month "-" dday

           GOBACK
           .
Task: Show the epoch


C++: #include <iostream>
#include <chrono>
#include <ctime>
int main()
{
    std::chrono::system_clock::time_point epoch;
    std::time_t t = std::chrono::system_clock::to_time_t(epoch);
    std::cout << std::asctime(std::gmtime(&t)) << '\n';
    return 0;
}








COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. epoch.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  epoch-date.
           03  year                PIC 9(4).
           03  month               PIC 99.
           03  dday                PIC 99.

       PROCEDURE DIVISION.
           MOVE FUNCTION DATE-OF-INTEGER(1) TO epoch-date

           DISPLAY year "-" month "-" dday

           GOBACK
           .
Task: Show the epoch





Java: import java.text.DateFormat;
import java.util.Date;
import java.util.TimeZone;

public class DateTest{
    public static void main(String[] args) {
        Date date = new Date(0);
        DateFormat format = DateFormat.getDateTimeInstance();
        format.setTimeZone(TimeZone.getTimeZone("UTC"));
        System.out.println(format.format(date));
    }
}





COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. epoch.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  epoch-date.
           03  year                PIC 9(4).
           03  month               PIC 99.
           03  dday                PIC 99.

       PROCEDURE DIVISION.
           MOVE FUNCTION DATE-OF-INTEGER(1) TO epoch-date

           DISPLAY year "-" month "-" dday

           GOBACK
           .
Task: Show the epoch







Python: >>> import time
>>> time.asctime(time.gmtime(0))
'Thu Jan  1 00:00:00 1970'
>>>



COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. epoch.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  epoch-date.
           03  year                PIC 9(4).
           03  month               PIC 99.
           03  dday                PIC 99.

       PROCEDURE DIVISION.
           MOVE FUNCTION DATE-OF-INTEGER(1) TO epoch-date

           DISPLAY year "-" month "-" dday

           GOBACK
           .